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.
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:
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:attribute name="final" type="xs:simpleDerivationSet"/>
<xs:attribute name="name" type="xs:NCName">
Can be restricted to required or forbidden
<xs:element name="simpleType" type="xs:topLevelSimpleType"
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