<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification V2.6//EN"
               "http://www.w3.org/2002/xmlspec/dtd/2.6/xmlspec.dtd" [
  <!-- ================================================================ -->
  <!ENTITY draft.day "03">
  <!ENTITY draft.month "11">
  <!ENTITY draft.monthname "November">
  <!ENTITY draft.year "2003">
  <!ENTITY iso6.doc.date "&draft.year;-&draft.month;-&draft.day;">
  <!ENTITY http-ident "http://www.w3.org/2001/tag/doc/qnameids">
]>
<spec w3c-doctype='other'>
<?CVS $Id: qnameids-2003-11-03.xml,v 1.1 2003/11/04 14:10:00 NormanWalsh Exp $?>
<header>
<title>Using Qualified Names (QNames) as Identifiers in Content</title>
<w3c-designation>&http-ident;-&iso6.doc.date;</w3c-designation>
<w3c-doctype>[Editor’s Draft] TAG Finding</w3c-doctype>
<pubdate><day>&draft.day;</day>
<month>&draft.monthname;</month>
<year>&draft.year;</year>
</pubdate>
<publoc>
<loc href="&http-ident;-&iso6.doc.date;">&http-ident;-&iso6.doc.date;</loc>
</publoc>
<altlocs>
<loc href="&http-ident;-&iso6.doc.date;.xml">XML</loc>
<loc href="&http-ident;-&iso6.doc.date;-diff.html">2003-07-15 Diff</loc>
</altlocs>
<latestloc>
<loc href="&http-ident;">&http-ident;</loc>
</latestloc>
<prevlocs>
<loc href="&http-ident;-2002-07-15">&http-ident;-2002-07-15</loc>
<loc href="&http-ident;-2002-06-17">&http-ident;-2002-06-17</loc>
<loc href="&http-ident;-2002-06-04">&http-ident;-2002-06-04</loc>
<loc href="&http-ident;-2002-04-30">&http-ident;-2002-04-30</loc>
</prevlocs>
<authlist>
<author><name>Norman Walsh</name>
<affiliation>Sun Microsystems, Inc.</affiliation>
<email href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</email></author>
</authlist>
<copyright>
<p>
<loc href="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Copyright">Copyright</loc> &#xA9; 2002
<loc href="http://www.w3.org/">W3C</loc><sup>&#xAE;</sup>
(<loc href="http://www.lcs.mit.edu/">MIT</loc>,
<loc href="http://www.inria.fr/">INRIA</loc>,
<loc href="http://www.keio.ac.jp/">Keio</loc>),
All Rights Reserved. W3C
<loc href="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#Legal_Disclaimer">liability</loc>,
<loc href="http://www.w3.org/Consortium/Legal/ipr-notice-20000612#W3C_Trademarks">trademark</loc>,
<loc href="http://www.w3.org/Consortium/Legal/copyright-documents-19990405">document use</loc>, and
<loc href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">software licensing</loc>
rules apply.
</p></copyright>

<abstract>
<p>The question that prompted this finding was "are QNames acceptable replacements
for URIs as identifiers within specifications?" This finding documents the TAG's
opinion on the use of QNames as identifiers.</p>
</abstract>

<status>
<p>This document has been developed for discussion by the
<loc href="/2001/tag/">W3C Technical Architecture Group</loc>.
This finding addresses <loc href="http://www.w3.org/2001/tag/ilist#qnameAsId-18">issue
qnameAsId-18</loc>.</p>

<p>This finding was accepted by the TAG at its 
<loc href="/2002/07/22-tag-summary#Update">22 July 2002
teleconference</loc>. The TAG originally reached consensus on this finding
at its <loc href="/2002/07/15-tag-summary#Qnames">15 July 2002 teleconference</loc>.</p>

<p><loc href="/2001/tag/findings">Additional TAG findings</loc>, both
approved and in draft state, may also be available. The TAG expects to
incorporate this and other findings into a Web Architecture Document
that will be published according to the process of the <loc
href="/Consortium/Process-20010719/tr#Recs">W3C Recommendation
Track</loc>.</p>

<p>Please send comments on this finding to the publicly archived TAG
mailing list <loc
href="mailto:www-tag@w3.org">www-tag@w3.org</loc>
(<loc
href="http://lists.w3.org/Archives/Public/www-tag/">archive</loc>).</p>

</status>
<pubstmt>
<p>Chicago, Vancouver, Mountain View, et al.: World-Wide Web Consortium,
Draft TAG Finding, 2002.</p>
</pubstmt>
<sourcedesc>
<p>Created in electronic form.</p>
</sourcedesc>
<langusage>
<language id="EN">English</language>
</langusage>
<revisiondesc>
<slist>
<sitem>2002-04-30: Published draft</sitem>
</slist>
</revisiondesc>
</header>
<body>

<div1 id="preface">
<head>Preface</head>

<p>This TAG Finding documents a
portion of the web architecture where conflicting requirements and
design goals intersect. It is a simple matter of fact that
specifications which have chosen one set of design criteria
interoperate less well with specifications that have chosen a
different set.</p>

<p>Given that there are existing specifications which exhibit
incompatible designs and strong arguments in favor of each design, the
TAG elects not to assert architectural principles that would be in
direct conflict with some significant set of specifications.</p>

<p>It's possible that these issues could be addressed in the scope of
some larger, more global redesign of, for example, XML, but no
short-term solution presents itself</p>
</div1>

<div1 id="sec-qnamesids">
<head>QNames as Identifiers</head>

<p>This finding is concerned with the use of qualified names (QNames)
as identifiers. That is, the contexts in which a colonized name can be
understood to be a QName.</p>

<p>A related TAG issue, <loc
href="http://www.w3.org/2001/tag/ilist#rdfmsQnameUriMapping-6">rdfmsQnameUriMapping-6</loc>,
concerns the mechanism by which one can (or can not) construct a URI
for a particular QName. We do not consider that issue in this finding.</p>

</div1>

<div1 id="sec-qnames-xml">
<head>QNames in XML</head>

<p>Qualified names were introduced by <bibref
ref="xml-names"/>. They were defined for element and attribute
<emph>names</emph> (only) and provide a mechanism for concisely
identifying a URI/local-name pair. For example, in the following document:</p>

<eg><![CDATA[
<?xml version='1.0'?>
<doc xmlns:x="http://example.com/ns/foo">
<x:p/>
</doc>]]></eg>

<p>The QName <quote><code>x:p</code></quote> is a concise, unambiguous name
for the URI/local-name pair <code>{"http://example.com/ns/foo", "p"}</code>.</p>

<p>When used solely in element and attribute names, all QNames are
identified by the XML processor and can logically be replaced by the
URI/local-name pair they identify.</p>

<div2 id="sec-cname-ids">
<head>Prefixes in Other Contexts</head>

<p>At the request of the XML Schema Working Group, the XML Core
Working Group is producing
<loc href="http://www.w3.org/XML/xml-names-19990114-errata#NE08">an erratum</loc>
to <bibref ref="xml-names"/> to clarify the meaning of colons in other
contexts.</p>

<p>In particular, this erratum makes it clear that entity names,
processing instruction targets, and notation names are not QNames and
they may not include any colons. Documents that do not satisfy this
constraint are not namespace well-formed. Furthermore, the
<emph>values</emph> of attributes of type ID, IDREF(S),
ENTITY(IES), and NOTATION are also forbidden from containing colons.
Documents that do not satisfy this constraint are not namespace valid.
</p>

<p>A colon that introduces a namespace validity or namespace
well-formedness error into a document <emph>does not</emph> introduce
a QName. In other words, the term "identifier" in this finding is not
related to XML identifiers of type ID since they cannot be QNames.</p>

</div2>
</div1>

<div1 id="sec-qnames-other">
<head>QNames in Other Specifications</head>

<p>Other specifications, starting with <bibref ref="xslt"/>,
have taken QNames and employed them in contexts other than element and
attribute names. Specifically,
QNames have been used in attribute <emph>values</emph>
and element <emph>content</emph>.
</p>

<p>For example, in the following document,
<quote><code>x:p</code></quote> is understood to be a QName even though it
appears in an attribute value, not an element or attribute name.</p>

<eg><![CDATA[
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                xmlns:x="http://example.com/ns/foo"
                version="1.0">

<xsl:output method="html"/>

<xsl:template match="x:p">
  <p>
    <xsl:apply-templates/>
  </p>
</xsl:template>

</xsl:stylesheet>
</doc>]]></eg>

<p>In attribute values and element content, QNames are often used to
identify a particular element type; they are, in principle, using
QNames as they were intended. However, some specifications use QNames
as shortcuts for unique identifiers derived from a URI/local-name pair
that have no relationship to element or attribute types.</p>

<p>Using a QName as a shortcut for a URI/local-name pair is often
convenient, but it carries a price. There is no single, accepted way
to convert QNames into URI/local-name pairs or vice versa. Different
specifications have chosen different algorithms. This means that even
if a QName can be identified in content, it may be difficult or
impossible to determine what URI/local-name it represents. At the very
least, the mapping depends on the context in which it occurs.
Therefore, at the very least, it is important for specifications to
identify the mapping algorithm that they have chosen.</p>

<p role="principle">Specifications that use QNames to represent
URI/local-name pairs MUST describe the algorithm that is used to
map between them.</p>

<p>We observe also that there is an overlap in the lexical space of
QNames and URIs.</p>

<p role="practice">Specifications that use QNames to represent
URI/local-name pairs SHOULD NOT allow both forms in attribute values
or element content where they would be indistinguishable.</p>

</div1>

<div1 id="bindings">
<head>Namespace Bindings</head>

<p>Some specifications rely on the in-scope namespace bindings in the
XML document to associate prefixes with namespace names. Other
specifications rely on application-specific mechanisms.</p>

<p>Using the in-scope namespace bindings has the advantage that it
theoretically allows a generic processor to interpret QNames in
content without having to be aware of any application-specific
mechanisms. The alternative, where every specification defines its own
mechansism, could clearly lead to a badly fragmented web.</p>

<p>However, there is at least one application where a compelling argument
has been made for <emph>requiring</emph> an alternative mechanism for defining
namespace bindings. That application is <bibref ref="xpointer-framework"/>.
</p>

<p>It is an architectural principle of URIs that they be
context-independent. It follows that the QNames that appear in an
XPointer must not refer to in-scope namespaces as this would make
transcription impossible in the general case.</p>

<p>We must therfore accept that there are some applications which use
in-scope namespaces and some which use their own mechanisms.</p>
</div1>

<div1 id="sec-archobs">
<head>Architectural Observations</head>

<p>The TAG makes the following observations:</p>

<ulist>

<item><p>Whatever the architectural ramifications of using QNames as
identifiers in contexts other than XML element and attribute names, it
is already established practice.</p>

<p>It is simply not practical to suggest that this usage should be
forbidden on architectural grounds.</p>

</item>

<item><p>Using QNames in untyped (<code>#PCDATA</code> or
<code>xs:string</code>) attribute values or element content places an additional
burden on the processor that was not anticipated by <bibref ref="xml-names"/>.
</p>

<p>If QNames are only used in element and attribute
<emph>names</emph>, the processor can fully resolve all of the
prefixes as it parses. This gives it the freedom to discard the
prefix-to-URI mappings when they go out of scope. A serializer,
presented with an object model that conforms to <bibref
ref="xml-names"/> can manufacture new prefixes on the fly. (In
practice, users expect most prefixes to be preserved through
transformations, so things aren't quite this simple for most
developers, but this is still theoretically the case.)</p>

<p>As soon as QNames may appear in element or attribute
<emph>values</emph>, the processor must retain all of the
prefix-to-URI mappings (and any API must expose these mappings). This
is necessary because some subsequent micro-parser, in the course of
examining some content, may encounter a token that it recognizes as a
QName and need to find its URI/local-name.</p>

<p>In our previous XSL example, from the perspective of the XML processor,
there are no qualified names that use the <code>x:</code> prefix. However, when
the <emph>XSL</emph> processor examines the <att>match</att> attribute on
<el>xsl:template</el>, it must be able to resolve the <code>x:</code> prefix.</p>

</item>
<item><p>QNames in attribute values or element content <emph>by
themselves</emph>, in other words, in contexts that could be typed as
<code>xs:QName</code> (<bibref ref="xmlschema-2"/>) in a schema,
could in principle be identified by
the schema processor.</p>

<p>For example, given:</p>

<eg><![CDATA[<elem ref="data:myInteger"/>]]></eg>

<p>If schema validation reveals that the following component applies to this
instance of the <el>elem</el> element:</p>

<eg><![CDATA[<xs:complexType name="elemType">
  <xs:complexContent>
    <xs:restriction base="xs:anyType">
      <xs:attribute name="ref" type="xs:QName"/>
    </xs:restriction>
  </xs:complexContent>
</xs:complexType>]]></eg>

<p>The schema processor can determine that <code>data:myInteger</code> is a QName
and must therefore be a concise name for the URI/local-name pair consisting
of the in-scope namespace URI for the prefix <code>data</code> and the local-name
<code>myInteger</code>.</p>
</item>

<item><p>Perhaps the most common use of QNames in untyped values at the
moment is in locations where XPath expressions may occur. As XPath is
reused in more and more specifications, it may eventually be reasonable to
define an XPath data type to identify all of these values in a way that makes
them accessible to higher-level parsers.</p>
</item>

<item><p>Some specifications rely on mechanisms other than in-scope
namespaces to associate prefixes with namespace names. In general,
therefore, even when <emph>all</emph> of the in-scope namespace declarations
are available, there may still be prefixes which can only be known in
an application-dependent manner.</p>
</item>

</ulist>

</div1>

<div1 id="sec-archrec">
<head>Architectural Statement</head>

<p>The TAG recognizes that there are pragmatic reasons why it is
desireable to provide the same kind of URI/local-name shortcuts that
QNames provide for element and attribute names in other contexts. In
addition, the practice is already well established. Therefore, the TAG
accepts that it is reasonable to use QNames in this way.</p>

<p>Specifications that have no compelling reason to use QNames where URIs would
suffice, for example formats that are not expected to be edited by hand or
formats where human readability is not a significant factor, can avoid
an entire set of problems by simply using URIs.</p>

<p>The TAG encourages designers to consider the ramifications of their
use of QNames carefully as it may have a dramatic impact on the extent to which
their specification interoperates with other specifications.</p>

</div1>

<div1 id="references">
<head>References</head>

<blist>
<bibl id="xpointer-framework" href="http://www.w3.org/TR/xptr-framework/"
key="XPointer Framework">Paul Grosso, Eve Maler, Jonathan Marsh, Norman
Walsh, editors. <titleref>XPointer Framework</titleref>.
World Wide Web Consortium, 2002.</bibl>

<bibl id="xmlschema-2" href="http://www.w3.org/TR/xmlschema-2/" key="XML Datatypes">Paul V. Biron
and Ashok Malhotra, editors. <titleref>XML Schema Part 2: Datatypes</titleref>.
World Wide Web Consortium, 2000.
</bibl>

<bibl id="xml-names" href="http://www.w3.org/TR/REC-xml-names/"
key="XML Namespaces">Tim Bray, Dave Hollander, Andrew Layman, editors.
<titleref>Namespaces in XML</titleref>.
World Wide Web Consortium, 1999.</bibl>

<bibl id="xslt" href="http://www.w3.org/TR/xslt" key="XSLT">James
Clark, editor. <titleref>XML
Transformations (XSLT) Version 1.0</titleref>. World Wide Web
Consortium,
1999.</bibl>

</blist>

</div1>

</body>
</spec>
