QNames are used in XML to describe namespace qualified elements and attributes. A QName has the syntax (prefix ':' localname) where the prefix is bound to a namespace URI. QNames are specified in the XML Namespaces recommendation as a method providing 2 part namespace qualified names yet are extended by other W3C recommendations such as XML Schema and RDF as a way to name concepts such as datatypes.

A quagmire is arising regarding these usages of QNames being used to name things in different ways in different specifications. Such outwardly appearing subtle, even arcane, differences, threaten to do great damamge to the ability to use W3C specifications together in a coherent fashion. This article explores some of these subtle differences in identifying resources based on QNames and URIs.

XML Schema's use of QNames

The recent release of the final XML Schema 1.0 Recommendation sets in stone a particular use of QNames as values and allows us to examine the XML Schema mapping of QNames to URIs. This is described in http://www.w3.org/TR/xmlschema-2/#built-in-datatypes .

A QName describing a type is created from the namespace URI of the schema defining the type and the value of the name attribute on the type definition. The XML Schemas defining XML Schema itself provide an additional id attribute value which is used to construct a URI reference. For example:

   <xs:simpleType name="int" id="int">
-    <xs:annotation>
         <xs:documentation source="http://www.w3.org/TR/xmlschema-2/#int" />
-    <xs:restriction base="xs:long">
        <xs:minInclusive value="-2147483648" id="int.minInclusive" />
        <xs:maxInclusive value="2147483647" id="int.maxInclusive" />
The URI reference:
is specified as the URI for the XML Schema concept "int" which corresponds to the QName "xs:int" (it is implied that the QName prefix "xs" is bound to the URI http://www.w3.org/2001/XMLSchema).
This mapping of QName to URI is consistent with what we expect from HTML where the value of the ID attribute serves as a fragment identifier for a URI reference.
Unfortunately RDF uses a different mapping to create a URI from a QName: simple concatenation of the namespace URI and local name. For example the RDF snippet:
<rdf:RDF xmlns:rdf="http://www.w3.org/2000/01/22-rdf-syntax#"
  <rdf:Description rdf:about="http://example.org/foo">
should produce the triple:
[http://example.org/foo, http://www.w3.org/2001/XMLSchema#int, "35"]
but instead produces:
[http://example.org/foo, http://www.w3.org/2001/XMLSchemaint, "35"]
The 'problem' is that the RDF Model and Syntax 1.0 recommendation specifies that a URI is constructed from a QName by string concatentation of the namespace URI and local name (as opposed to XML Schema which uses the local name as the fragment identifier).
This results in problems for applications such as DAML (http://www.daml.org) which specify use of XML Schema datatypes in RDF documents.

Complex types

The QName -> URI mapping problem gets worse for XML Schema complex types. The general XML Schema datatype mechanism uses the value of the name attribute as the local name part of the datatype QName. The difficulty arrises in that this name value can be overloaded among attribute, element and type definitions. For example the definition:

<xs:complexType name="simpleType" abstract="true">
      <xs:extension base="xs:annotated">
        <xs:group ref="xs:simpleDerivation"/>
        <xs:attribute name="final" type="xs:simpleDerivationSet"/>
        <xs:attribute name="name" type="xs:NCName">
              Can be restricted to required or forbidden

and later:

<xs:element name="simpleType" type="xs:topLevelSimpleType" id="simpleType">

both are referred to by the QName "xs:simpleType"

Indeed the MSL, now "XML Schema: Formal Description" WD  invents a new fragment identifier syntax (see http://www.w3.org/TR/xmlschema-formal/#section-overview-normalization) in order to properly identify components of a schema.

Fragment Identifier Hell

The problem this creates, in the intertwined specification quagmire, is that the fragment identifier syntax is dependent on the media type of a document. For example according to RFC 3023, the media type application/xml uses specifies XPointer as the fragment identifier syntax. A new fragment identifier syntax for XML Schema would need to use a new media type (e.g. application/w3c-schema+xml) yet the XML Schema specification prefers the media type application/xml). These issues need to be thought through and coordinated.

What does this all mean.

At the very least, the RDF XML Syntax, which is currently being revised, at the very least needs to interoperate with and use XML Schema builtin datatypes. This can be accomplished in a relatively straightforward fashion using the following rule for creating a URI from a QName: When the namespace URI ends in an alphanumeric character treat the local name as a fragment identifier, i.e. insert a '#' between the URI and localname. When the namespace URI ends in a character other than an alphanumeric the current system of simple concatentation is used. The effect of this would be negligable for current applications because essentially all RDF applications use namespaces that end in '#' or '/' (for the very reason that otherwise there are problems).

I have written an XSLT stylesheet that implements a simplified RDF XML syntax, parses arbitrary XML as RDF and is available at: http://www.openhealth.org/RDF/rdfExtractify.xsl