﻿<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="xmlspec-extended.xsl"?>
<!DOCTYPE spec PUBLIC "-//W3C//DTD Specification Version 2.0//EN"
                      "xmlspec.dtd" [
<!ENTITY year "2004">
<!ENTITY month "November">
<!ENTITY day "09">
<!ENTITY MM "11">
<!ENTITY DD "09">
<!ENTITY MMDD "&MM;&DD;">
<!ENTITY XMLCore-IPR "http://www.w3.org/2002/08/xmlcore-IPR-statements">
<!ENTITY internalXmlid "http://www.w3.org/XML/Group/&year;/xmlcore/xmlid/xml-id">
<!ENTITY externalXmlid "http://www.w3.org/TR/&year;/WD-xml-id-&year;&MMDD;/">
<!ENTITY xmlid "&externalXmlid;">
<!-- DTD Extensions -->
<!ENTITY % local.list.class "|options-list">
<!ELEMENT options-list (item+)>
<!ATTLIST options-list
diff (chg | add | del | off) #IMPLIED
role NMTOKEN #IMPLIED
id ID #IMPLIED
spacing (normal | compact) #IMPLIED
>
<!ATTLIST resolution
href CDATA #IMPLIED
>
]>
<spec w3c-doctype="wd">
<header>
<title>xml:id</title>
<version>Version 1.0</version>
<w3c-designation>xml-id-&year;&MMDD;</w3c-designation>
<w3c-doctype>W3C Working Draft</w3c-doctype>
<pubdate>
<day>&day;</day>
<month>&month;</month>
<year>&year;</year>
</pubdate>
<publoc>
<loc href="&xmlid;">&xmlid;</loc>
</publoc>
<altlocs>
<loc href="&xmlid;WD-xml-id-&year;&MMDD;.xml">XML</loc>
</altlocs>
<latestloc>
<loc href="http://www.w3.org/TR/xml-id/">http://www.w3.org/TR/xml-id/</loc>
</latestloc>
<prevlocs>
<loc href="http://www.w3.org/TR/2004/WD-xml-id-20040407/">http://www.w3.org/TR/2004/WD-xml-id-20040407/</loc>
</prevlocs>
<authlist>
<author>
<name>Jonathan Marsh</name>
<affiliation>Microsoft</affiliation>
<email href="mailto:jmarsh@microsoft.com">jmarsh@microsoft.com</email>
</author>
<author>
<name>Daniel Veillard</name>
<affiliation>Invited Expert</affiliation>
<email href="mailto:daniel@veillard.com">daniel@veillard.com</email>
</author>
<author>
<name>Norman Walsh</name>
<affiliation>Sun Microsystems</affiliation>
<email href="mailto:Norman.Walsh@Sun.COM">Norman.Walsh@Sun.COM</email>
</author>
</authlist>
<status>
<p><emph>This section describes the status of this document at the
time of its publication. Other documents may supersede this document.
A list of current W3C publications and the latest revision of this
technical report can be found in the
<loc href="http://www.w3.org/TR/">W3C technical reports index</loc> at
http://www.w3.org/TR/.</emph></p>

<p>This is a Last Call Working Draft of “xml:id Version 1.0”. The
Last Call review period ends 13 December 2004, at 23:59 EST.
Please send Last Call review comments on this document before that
date to the public mailing list
<loc
href="mailto:public-xml-id@w3.org">public-xml-id@w3.org</loc>
(<loc
href="http://lists.w3.org/Archives/Public/public-xml-id/">archive</loc>).Last Call Working Draft status is described in
<loc href="http://www.w3.org/2003/06/Process-20030618/tr.html#last-call">section
7.4.2</loc> of the W3C Process Document. To the extent possible, please
provide a separate email message for each distinct comment.</p>

<p>This document has been developed by the
<loc href="http://www.w3.org/XML/Core/">W3C XML Core Working Group</loc> as
part of the <loc href="http://www.w3.org/XML/Activity">XML
Activity</loc>.
Publication as a Working Draft does not imply endorsement by the W3C Membership.
This is a draft document and may be updated, replaced or obsoleted by
other documents at any time. It is inappropriate to cite this document
as other than work in progress.
</p>

<p>The patent policy for this document is the <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/">5 February
2004 W3C Patent Policy</loc>. 
Patent disclosures relevant
to this specification may be found on the 
<loc href="http://www.w3.org/2004/01/pp-impl/18796/status">XML Core
Working Group's public IPR disclosure page</loc>.
An individual who has actual knowledge of
a patent which the individual believes contains Essential Claim(s) with
respect to this specification should disclose the information in
accordance with <loc
href="http://www.w3.org/Consortium/Patent-Policy-20040205/#sec-Disclosure">section
6 of the W3C Patent Policy</loc>.
</p>
</status>
<abstract>
<p>This document defines the meaning of the attribute
<att>xml:id</att> as a universal spelling for ID attributes in XML
documents and defines processing of this attribute to identify IDs in
the absence of validation, without fetching external resources, and without
relying on an internal subset.</p>
</abstract>
<langusage>
<language id="EN">English</language>
</langusage>
<revisiondesc>
<slist>
<sitem>July 17, 2003: First Working Draft.</sitem>
<sitem>March 17, 2004: Second internal Working Draft.</sitem>
</slist>
</revisiondesc>
</header>
<body>
<div1 id="intro">
<head>Introduction</head>

<p><bibref ref="XML"/> and <bibref ref="XML11"/> provide a mechanism
for annotating elements with unique identifiers. This mechanism
consists of declaring the type of an attribute as "ID", after which
the parser will validate that</p>

<ulist>
<item><p>the ID value matches the allowed lexical
form,</p></item>
<item><p>the value is unique within the XML document, and that</p></item>
<item><p>each element has at most a single unique identifier</p>
</item>
</ulist>

<p>Declarations in either the
internal or external subset of an XML document can declare attributes
to be of type ID.
However, some specifications, notably
<bibref ref="SOAP"/>, forbid an internal subset, and processing 
the external subset is optional for conformant XML
processors, leaving no guarantee that all consumers of the XML
document will be able to successfully recognize the identifiers.</p>

<p>Identifiers can be declared through external mechanisms as well. Of
particular interest is <bibref ref="XMLSchemas"/> which provides a
type "xs:ID" with the same uniqueness and validity constraints as XML.
However, there are no guarantees that consumers will have the
"correct" schema available, nor that they will process it if they
do.</p>

<p>A mechanism allowing unique element identifiers to be recognized by
all conformant <loc href="http://www.w3.org/TR/REC-xml/#dt-xml-proc">XML
processors</loc>, whether they validate or not, is
desirable in making XML sub-resource linking robust.</p>

<p>An additional problem is that DTD-based and XML Schema-based
identifiers are exposed through different conceptual mechanisms - the
<emph role="infoset-property">attribute type</emph> infoset property,
and the <emph role="infoset-property">type definition</emph> family of
properties respectively. A uniform mechanism for recognizing
identifiers is desirable.</p>

<p>This specification provides such a mechanism: it describes the
semantics of <att>xml:id</att> attributes. This specification has been
designed to be a separate layer in processing and to be compatible
with existing validation technologies. Implementors are encouraged to
support <att>xml:id</att> processing and to make
<termref def="dt-id-assignment">ID assignment</termref> the default
behavior of their processors.
</p>

</div1>
<div1 id="terminology">
<head>Terminology</head>
<p>
<termdef id="dt-must" term="Must, May, etc.">The key words 
<term>must</term>, <term>must not</term>, <term>required</term>,
<term>shall</term>, <term>shall not</term>, <term>should</term>, 
<term>should not</term>, <term>recommended</term>, <term>may</term>, 
and <term>optional</term> in this specification are to be interpreted 
as described in <bibref ref="RFC2119"/>.</termdef>
</p>

<p><termdef id="dt-xml-id-proc" term="xml:id processor">An
<term>xml:id processor</term> is a software module that works in
conjunction with an <loc href="http://www.w3.org/TR/REC-xml/#dt-xml-proc">XML
processor</loc> to provide access to the IDs in an XML document.</termdef>
</p>

<p><termdef id="dt-xml-id-error" term="xml:id error">An
<term>xml:id error</term> is a non-fatal error that occurs when an
<termref def="dt-xml-id-proc">xml:id processor</termref> finds that
a document has violated the constraints of this specification.</termdef>
</p>

<p>Validation is the process of comparing an XML document (or part of
an XML document) against a grammar or set of rules to determine if the
actual structure of the document satisfies the constraints of the
grammar or the rules. Some validation technologies also perform type
assignment, determining not only if the document satisfies the
specified constraints but also determining, for example, which
(elements and/or) attributes are of type “ID”.</p>

<p>Although often performed together, validation and type assignment
are not the same process. A non-validating XML 1.0 processor, for
example, can perform type assignment using only declarations from the
internal subset, without ever having any information about the
structural validity of the document.</p>

<p><termdef id="dt-id-assignment" term="ID assignment">The process of
<term>ID assignment</term> associates an ID with an element.</termdef>
This is often achieved by promoting the type of an untyped element or
attribute value to a value of type “ID”, but that is not the only
possible mechanism.</p>

</div1>

<div1 id="syntax">
<head>Syntax</head>
<p>Per <bibref ref="XMLNS"/> (and <bibref ref="XMLNS11"/>), prefixes
beginning “xml” are reserved for use by XML and XML-related
specifications. This specification licenses the use of the attribute
“xml:id” for use as a common syntax for identifiers in XML with the
semantics specified herein.</p>

<p>Authors of XML documents are encouraged to name their ID attributes
"xml:id" to increase the interoperability of these identifiers on the
Web.</p>

<p>In namespace-aware XML processors, the "xml" prefix is bound to the
namespace name <code>http://www.w3.org/XML/1998/namespace</code> as
described in Namespaces in XML <bibref ref="XMLNS"/> (and <bibref
ref="XMLNS11"/>). Note that <att>xml:id</att> can be still used by
non-namespace-aware XML processors.</p>
</div1>

<div1 id="processing">
<head>Processing <att>xml:id</att> Attributes</head>

<p>Each <att>xml:id</att> attribute is processed in the following
way:</p>

<olist>
<item>
<p>The attributeʼs value is normalized according to the rules
for <loc href="http://www.w3.org/TR/REC-xml/#AVNormalize">attribute-value
normalization</loc> on attributes of type ID. For <att>xml:id</att>
processors operating on an infoset or some other output from an XML parser,
the value will already be normalized, but
unless the parser normalized it as a value of type ID it will still be
necessary
for the processor to trim leading and trailing space (#x20) characters
and replace sequences of space characters by a single space.</p>
</item>
<item>
<p><termref def="dt-id-assignment">ID assignment</termref> is
performed.</p>
</item>
</olist>

<p>An <att>xml:id</att> processor
<termref def="dt-must">must</termref> assure that the following
constraints hold for all <att>xml:id</att> attributes:</p>

<ulist>
<item>
<p>The normalized value of the attribute is a valid
<loc href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</loc>.
</p>
</item>
<item>
<p>The declared type of the attribute, if it has one, is “ID”.
All declarations for <att>xml:id</att> attributes
<termref def="dt-must">must</termref>
specify “ID” as the type of the attribute.</p>
</item>
</ulist>

<p>An <att>xml:id</att> processor
<termref def="dt-must">should</termref> assure that the following
constraints hold:</p>

<ulist>
<item>
<p>The values of all <att>xml:id</att> attributes and all attributes
of type “ID” within a document are unique.</p>
</item>
</ulist>

<p>An <termref def="dt-xml-id-error">xml:id error</termref> occurs
for any <att>xml:id</att> attribute that does not satisfy the
constraints.</p>

<p>The <att>xml:id</att> processor performs 
<termref def="dt-id-assignment">ID assignment</termref> on all
<att>xml:id</att> attributes, even those that do not satisfy
the enumerated constraints.</p>

<p>An <att>xml:id</att> processor
<termref def="dt-must">should</termref> update the
<emph role="infoset-property">references</emph> infoset property, and/or
other appropriate referential properties to reflect the results of ID
assignment.
</p>

<p>Many validation technologies impose the constraint that an XML
element can have at most one attribute of type ID. That constraint is
<emph>not</emph> imposed by <att>xml:id</att> processing.</p>

</div1>

<div1 id="inform">
<head>Informing the Application</head>

<p><termref def="dt-id-assignment">ID assignment</termref> may be
performed when <att>xml:id</att> attributes are processed.
If ID assignment
occurs, then the <termref def="dt-xml-id-proc">xml:id processor</termref>
<termref def="dt-must">must</termref> report the assigned
<att>xml:id</att> attributes
to the application. How this is reported is implementation
dependent.</p>

<ulist>
<item id="Attribute_type">
<p>For applications that operate conceptually on the Infoset, an
<att>xml:id</att> processor can use the
<emph role="infoset-property">attribute type</emph> Infoset
property:</p>

<p>The <att>xml:id</att> processor <termref
def="dt-must">may</termref> report the results of ID assignment in a
DTD compatible manner by setting the <emph
role="infoset-property">attribute type</emph> infoset property of the
attribute to ID.</p>
</item>

<item id="type_definition">
<p>For applications that operate conceptually on the PSVI, an
<att>xml:id</att> processor can use the
<emph role="infoset-property">type definition</emph> family
of PSVI properties:</p>

<p>The <att>xml:id</att> processor <termref def="dt-must">may</termref>
report the results of ID assignment
in an XML Schema compatible manner by setting the PSVI
<emph role="infoset-property">type definition</emph> property of the
attribute to <code>xs:ID</code>.</p>
</item>

<item id="other_mechanisms">
<p>For applications that operate on data models defined in other ways,
the mechanisms are implementation dependent:</p>

<p>The <att>xml:id</att> processor <termref def="dt-must">may</termref>
report the results of ID assignment in some other way.</p>
</item>
</ulist>

<p>The key requirement is that the application be made aware of the results
of ID assignment.</p>

</div1>

<div1 id="errors">
<head>Errors</head>

<p>A violation of the constraints in this specification results in an
<termref def="dt-xml-id-error">xml:id error</termref>.
Such errors are not fatal, but <termref def="dt-must">must</termref>
be reported by the
<termref def="dt-xml-id-processor">xml:id processor</termref>
to the application invoking it.</p>

</div1>

<div1 id="conformance">
<head>Conformance</head>

<div2 id="xmlid-conformance">
<head>Conformance to xml:id</head>

<p>Conformance to <att>xml:id</att> for applications that rely on
<loc href="http://www.w3.org/TR/2004/REC-xml-20040204/#dt-xml-proc">XML
processors</loc> using validation technologies consists in the
use of the <att>xml:id</att> construct as explained in
<specref ref="processing"/> and by conformance to both the constraints
of this specification and the rules of the validation technology.</p>

<p>Conformance to <att>xml:id</att> for applications that rely on
non-validating
<loc href="http://www.w3.org/TR/2004/REC-xml-20040204/#dt-xml-proc">XML
processors</loc> is defined by the recognition of <att>xml:id</att>
attributes as explained in 
<specref ref="processing"/> and by conformance to the constraints
of this specification.</p>
</div2>

<div2 id="infoset">
<head>XML Information Set Conformance</head>
<p>This specification conforms to the <bibref ref="XMLIS"/>.
The following information items <termref def="dt-must">must</termref> 
be present in the input infosets to enable correct processing:</p>
<ulist>
<item>
<p>
<emph role="info-item">Element Information Items</emph> with
<emph role="infoset-property">attributes</emph> property.</p>
</item>
<item>
<p>
<emph role="info-item">Attribute Information Items</emph> with
<emph role="infoset-property">namespace name</emph>,
<emph role="infoset-property">local name</emph> and
<emph role="infoset-property">normalized value</emph> properties.</p>
</item>
</ulist>
<p>In addition, the following properties might be present in the output infoset:</p>
<ulist>
<item>
<p>
<emph role="infoset-property">attribute type</emph> properties on <emph role="info-item">Attribute Information Items</emph>.</p>
</item>
</ulist>
</div2>
</div1>
</body>
<back>
<div1 id="references">
<head>References</head>
<blist>
<bibl id="RFC2119" key="IETF RFC 2119" href="http://www.ietf.org/rfc/rfc2119.txt">
<titleref href="http://www.ietf.org/rfc/rfc2119.txt">RFC 2119: Key 
words for use in RFCs to Indicate Requirement Levels</titleref>.
Internet Engineering Task Force, 1997.
</bibl>
<bibl id="XML" key="XML 1.0" href="http://www.w3.org/TR/REC-xml/">
Tim Bray, Jean Paoli, C.M. Sperberg-McQueen, et. al., editors.
<titleref href="http://www.w3.org/TR/REC-xml/">Extensible Markup 
Language (XML) 1.0 (Third Edition).</titleref>
World Wide Web Consortium, 2004.
</bibl>
<bibl id="XML11" key="XML 1.1" href="http://www.w3.org/TR/xml11/">
Tim Bray, Jean Paoli, C.M. Sperberg-McQueen, et. al., editors.
<titleref href="http://www.w3.org/TR/xml11/">Extensible Markup 
Language (XML) 1.1.</titleref>
World Wide Web Consortium, 2004.
</bibl>
<bibl id="XMLIS" key="XML Information Set" href="http://www.w3.org/TR/xml-infoset/">
John Cowan and Richard Tobin, editors.
<titleref href="http://www.w3.org/TR/xml-infoset/">XML Information Set (Second Edition).</titleref>
World Wide Web Consortium, 2004.
</bibl>
<bibl id="XMLNS" key="Namespaces in XML" href="http://www.w3.org/TR/REC-xml-names/">
Tim Bray, Dave Hollander, and Andrew Layman, editors.
<titleref href="http://www.w3.org/TR/REC-xml-names/">Namespaces in XML</titleref>.
World Wide Web Consortium, 1999.
</bibl>
<bibl id="XMLNS11" key="Namespaces in XML 1.1" href="http://www.w3.org/TR/xml-names11/">
Tim Bray, Dave Hollander, Andrew Layman, and Richard Tobin, editors.
<titleref href="http://www.w3.org/TR/xml-names11/">Namespaces in XML 1.1</titleref>.
World Wide Web Consortium, 2004.
</bibl>
</blist>
</div1>
<inform-div1>
<head>References</head>
<blist>
<bibl id="XMLSchemas" key="XML Schemas" href="http://www.w3.org/TR/xmlschema-1/">
Henry S. Thompson, David Beech, Murray Maloney, Noah Mendelsohn, editors.
<titleref href="http://www.w3.org/TR/xmlschema-1/">XML Schema Part 1: 
Structures.</titleref>
World Wide Web Consortium, 2001.
</bibl>
<bibl id="SOAP" key="SOAP" href="http://www.w3.org/TR/soap12-part1/">Martin
Gudgin, Marc Hadley, Noah Mendelsohn, et. al., editors.
<titleref href="http://www.w3.org/TR/soap12-part1/">SOAP Version 1.2 Part 1:
Messaging Framework</titleref>. World Wide Web Consortium, 2003.
</bibl>
</blist>
</inform-div1>
<inform-div1>
<head>Impacts on Other Standards</head>
<ulist>
<item>
<p><emph>XPath 1.0:</emph> The id() function only recognizes IDs
declared in the DTD. If <att>xml:id</att> processing is performed before
the document is provided to the XPath 1.0 processor, and if ID assignment is
performed by setting the
<emph role="infoset-property">attribute type</emph> infoset property,
XPath 1.0 will recognize <att>xml:id</att> attributes as IDs.
An erratum to XPath 1.0 would be required to allow
Schema-declared IDs to be included in the results of this function.</p>
</item>
<item>
<p><emph>XPath 2.0:</emph> No change required. The id() function
recognizes both DTD- and Schema-declared identifiers, and as such
would also recognize <att>xml:id</att> attributes identified with a
minimally conforming schema processor.</p>
</item>
<item>
<p><emph>Fragment Identifiers</emph> and the <emph>XPointer Framework:</emph>
No change required. Barename
fragment identifiers and the element() scheme recognize both DTD- and
Schema-declared identifiers, and as such would also recognize
<att>xml:id</att> attributes identified with a minimally conforming
schema processor.</p>
</item>
<item>
<p><emph>DOM:</emph> To the extent that a DOM instance is constructed from
an Infoset or PSVI, no change is required. The <att>xml:id</att> processorʼs
ID assignment of <att>xml:id</att> attributes will be visible to the
DOM construction process.</p>
</item>
<item>
<p><emph>CSS:</emph> To the extent that a CSS operates on a tree constructed from
an Infoset or PSVI, no change is required. The <att>xml:id</att> processorʼs
ID assignment of <att>xml:id</att> attributes will be visible to the
construction process.</p>
</item>
</ulist>
</inform-div1>
<inform-div1 id="validation-technologies">
<head>Validation Technologies</head>

<p>This appendix describes how <att>xml:id</att> processing interacts with
selected validation technologies.</p>

<div2 id="with-dtd-validation">
<head>With DTD Validation</head>

<p>DTD authors are encouraged to use <att>xml:id</att> exclusively in
their DTDs to indicate element identifiers.</p>

<p>The following (non-normative) DTD fragment illustrates a sample
declaration for the <att>xml:id</att> attribute:</p>

<eg>&lt;!ATTLIST someElement
    xml:id     ID          #IMPLIED
&gt;</eg>

<p>DTD authors <termref def="dt-must">must not</termref> declare
<att>xml:id</att> as something other than <code>ID</code>.
DTD authors who declare attributes other than <att>xml:id</att> as type
ID will not receive the full benefits of <att>xml:id</att> processing.
Such attributes may or may not be recognized processors, including
<code>xml:id</code> processors.</p>

<p>Validating consumers of documents using properly declared
<att>xml:id</att> attributes can recognize IDs through the <emph
role="infoset-property">attribute type</emph> property.</p>
</div2>

<div2 id="with-schema-validation">
<head>With XML Schema Validation</head>

<p>XML Schema authors are encouraged to use <att>xml:id</att>
exclusively in their schemas to indicate element identifiers.</p>

<p>The following (non-normative) XML Schema fragment illustrates a
sample declaration for the <att>xml:id</att> attribute:</p>

<eg><![CDATA[
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           targetNamespace="http://www.w3.org/XML/1998/namespace">

    <xs:attribute name="id" type="xs:ID"/>

</xs:schema>
]]></eg>

<p>XML Schema authors <termref def="dt-must">must not</termref>
declare <att>xml:id</att> as something other than <code>xs:ID</code>
(for instance <code>xs:string</code>).
XML Schema authors who declare attributes other than <att>xml:id</att> as type
xs:ID will not receive the full benefits of <att>xml:id</att> processing.
Such attributes may or may not be recognized processors, including
<code>xml:id</code> processors.</p>

<p>Consumers of documents validating the <att>xml:id</att> attributes
against an appropriate schema can recognize IDs through the <emph
role="infoset-property">type definition</emph> family of PSVI
properties.</p>

<p>Applications can recognize <att>xml:id</att> attributes as IDs by
conceptually using a <loc
href="http://www.w3.org/TR/xmlschema-1/#key-minimallyConforming">Minimally
Conforming Schema Processor</loc> processing the schema above.</p>

<p>Note that the effects of a Minimally Conforming Schema Processor,
processing the above schema, are approximated by simply looking for
attributes named <att>xml:id</att>, ensuring the value of such
attributes has the correct lexical form (<loc
href="http://www.w3.org/TR/REC-xml-names/#NT-NCName">NCName</loc>),
and the value is unique within the document.</p>

</div2>
</inform-div1>

</back>
</spec>
