<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
<?xml-stylesheet type="text/xsl" href="xml-names.xsl"?>
<!DOCTYPE spec SYSTEM "xml-names.dtd" [
 <!ENTITY iso6.doc.date "20021210">
 <!ENTITY directory "http://www.w3.org/TR/2002/CR-xml-names11-&iso6.doc.date;">
 <!ENTITY xmlspec "http://www.w3.org/TR/2000/REC-xml-20001006" >
 <!ENTITY XMLCore-IPR "http://www.w3.org/2002/08/xmlcore-IPR-statements">
 <!ENTITY xml11spec "" >
]>
<spec w3c-doctype="cr">
<header>
<title>Namespaces in XML</title>
<version>1.1</version>
<w3c-designation>xml-names11-&iso6.doc.date;</w3c-designation>
<w3c-doctype>W3C Candidate Recommendation</w3c-doctype>
<pubdate diff="chg"><day>10</day><month>December</month><year>2002</year></pubdate>
<publoc>
<loc href="&directory;/">&directory;/</loc>
</publoc>
<altlocs>
<loc href="&directory;/CR-xml-names11-&iso6.doc.date;.xml">XML</loc>
<!--
<loc href="&directory;/CR-xml-names11-&iso6.doc.date;-diff.html">HTML with differences highlighted</loc>
-->
</altlocs>
<latestloc>
<loc href="http://www.w3.org/TR/xml-names11/">
http://www.w3.org/TR/xml-names11/</loc>
</latestloc> 
<prevlocs>
<loc href="http://www.w3.org/TR/2002/WD-xml-names11-20020905/">
http://www.w3.org/TR/2002/WD-xml-names11-20020905/</loc>
</prevlocs>
<authlist>
<author><name>Tim Bray</name>
<affiliation>Textuality</affiliation>
<email 
href="mailto:tbray@textuality.com">tbray@textuality.com</email></author>
<author><name>Dave Hollander</name>
<affiliation>Contivo, Inc.</affiliation>
<email href="mailto:dmh@contivo.com">dmh@contivo.com</email></author>
<author><name>Andrew Layman</name>
<affiliation>Microsoft</affiliation>
<email href="mailto:andrewl@microsoft.com">andrewl@microsoft.com</email></author>
<author role="1.1" diff="add"><name>Richard Tobin</name>
<affiliation>University of Edinburgh and Markup Technology Ltd</affiliation>
<email href="mailto:richard@cogsci.ed.ac.uk">richard@cogsci.ed.ac.uk</email></author>
</authlist>

<status>

<p>This is the draft dated $Date: 2002/12/18 15:40:32 $</p>

<p>
<emph>
This section describes the status of this document at the time of its
publication. Other documents may supersede this document. The latest
status of this document series is maintained at the W3C.
</emph>
</p>

<p>
This specification is being put forth as a 
<loc href="http://www.w3.org/TR/#About">W3C Candidate Recommendation</loc>
of Namespaces in XML 1.1.
W3C publishes a technical report as a Candidate Recommendation to
indicate that the document is believed to be stable, and to encourage
implementation by the developer community.  Candidate Recommendation
status is described in
<loc href="http://www.w3.org/Consortium/Process-20010719/tr.html#RecsCR">
section 5.2.3 of the Process Document</loc>.
</p>

<p>
The
<loc href="http://www.w3.org/XML/Core/">XML Core Working Group</loc>
(part of the
<loc href="http://www.w3.org/XML/">XML Activity</loc>,
see <loc href="http://www.w3.org/XML/Activity">summary</loc>)
expects to request that the Director advance this specification to
Proposed Recommendation after the XML Core Working Group documents at
least two interoperable implementations. The two implementations must
be produced by different organizations.
</p>

<p>
The final version of this specification will refer to terms
and productions from the 1.1 revision of the XML specification.  Since
that specification does not yet exist in a suitable form, in this draft
they are links to the 1.0 specification where the difference is
unimportant, or links to placeholders within this draft.
</p>

<p>
There is a requirements document for this revision <bibref ref='req11'/>.  
</p>

<p>
The current 
<loc href="http://www.w3.org/XML/2002/12/xml-names11-implementation.html">implementation report</loc>
includes implementation feedback we have received to date.
</p>

<p>
Documentation of intellectual property possibly relevant to this
recommendation may be found at the Working Group's 
<loc href="&XMLCore-IPR;">public IPR disclosure page</loc>.
</p>

<p>
We explicitly invite comments on this draft. The Candidate
Recommendation review period ends at 2359 UTC on 14 February 2003.
Comments should be sent to 
<loc href="mailto:xml-names-editor@w3.org">xml-names-editor@w3.org</loc>.
This is the preferred method of providing feedback. Public comments
and their responses can be accessed at
<loc href="http://lists.w3.org/Archives/Public/xml-names-editor/">
http://lists.w3.org/Archives/Public/xml-names-editor/</loc>.
</p>

<p>
Publication as a Candidate Recommendation 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 a W3C Candidate Recommendation as anything other
than a "work in progress."  A list of current W3C Recommendations and
other technical documents can be found at
<loc href="http://www.w3.org/TR/">http://www.w3.org/TR</loc>.
</p>

</status> 

<abstract>
<p>XML namespaces provide a simple method for qualifying 
element and attribute
names used in Extensible Markup Language documents by associating them
with namespaces identified by <phrase diff="chg">IRI</phrase> references.</p>
</abstract>
<sourcedesc>
<p>Created in electronic form.</p>
</sourcedesc>
<langusage>
<language id='EN'>English</language>
<language id='ebnf'>Extended Backus-Naur Form (formal grammar)</language>
</langusage>
<revisiondesc>
<slist>
<sitem>1997-10-10 : TB : Assembled Andrew's material and mine</sitem>
</slist>
</revisiondesc>
</header>
<body> 
<div1 id='sec-intro'>
<head>Motivation and Summary</head>
<p>We envision applications of Extensible Markup Language (XML) where
a single XML document may
contain elements and attributes
(here referred to as a "markup vocabulary")
that are defined for and used by multiple software modules.
One motivation for this is modularity: if such a markup vocabulary exists
which is well-understood and for which there is useful software 
available, it is better to re-use this markup rather than re-invent it.
</p>
<p>Such documents, containing multiple markup vocabularies,
pose problems of recognition and collision.  Software modules need to
be able to recognize the elements and attributes which they are designed
to process, even in the face 
of "collisions" occurring when markup intended for some other software
package uses the same element <phrase diff="chg">name</phrase>
or attribute name.
</p>

<p diff="chg">
These considerations require that document constructs
should have have names constructed so as to avoid clashes
between names from different markup vocabularies.
This specification describes a mechanism,
<emph>XML namespaces</emph>, which accomplishes this
by assigning <termref def='dt-expname'>expanded names</termref>
to elements and attributes.
</p>

<div2 id='notation'>
<head>A Note on Notation and Usage</head>
<p>Note that many of the
nonterminals in the productions in 
this specification are defined not here but in
the XML specification <bibref ref='XML'/>.
When nonterminals defined here have the same names as nonterminals
defined in the XML specification, the productions here
in all cases match a subset of the strings matched by the 
corresponding ones there.
</p>
<p>In this document's productions, 
the <code>NSC</code> is a "Namespace Constraint", 
one of the rules that documents conforming to this specification must follow.
</p>
<p>Note that all Internet domain names used in
examples, with the exception of <code>w3.org</code>, are selected
at random and should not be taken as having any import.</p>
</div2>

</div1>

<div1 diff="chg" id='sec-namespaces'>
<head>XML Namespaces</head>

<div2 id="concepts">
<head>Basic Concepts</head>

<p>
<termdef id='dt-namespace' term='Namespace'>
An <term>XML namespace</term> is identified by
an <termref def='dt-IRI'>IRI reference</termref>;
element and attribute names
may be placed in an XML namespace using the mechanisms described
in this specification.
</termdef>
</p>

<p>
<termdef id='dt-expname' term='Expanded Name'>
An <term>expanded name</term>
is a pair consisting of a 
<termref def='dt-NSName'>namespace name</termref>
and a
<termref def='dt-localname'>local name</termref>.
</termdef>

<termdef id='dt-NSName' term='Namespace Name'>
For a name in a namespace, the
<term>namespace name</term>
is the IRI identifying the namespace.
For a name that is not in a namespace, the 
<term>namespace name</term>
is null.
</termdef>

<termdef id='dt-localname' term='Local Name'>
The
<term>local name</term>
is the name itself.
</termdef>

It is this combination of the universally managed IRI namespace
with the vocabulary's local names that is effective in avoiding
name clashes.
</p>

<p>
IRI references can contain characters not allowed in names, and are often
inconveniently long, so expanded names are not used directly to name
elements and attributes in XML documents.  Instead
<termref def='dt-qualname'>qualified names</termref>
are used.
<termdef id='dt-qualname' term='Qualified Name'>
A 
<term>qualified name</term>
is a name subject to namespace interpretation.
</termdef>
In documents conforming to this specification,
element and attribute names appear as qualified names.
Syntactically, they are either
<termref def='NT-PrefixedName'>prefixed names</termref> or
<termref def='NT-UnprefixedName'>unprefixed names</termref>.
An attribute-based declaration syntax is provided to bind prefixes to
namespace names and to bind a default namespace that applies to
unprefixed element names;
these declarations are scoped by the elements on which they appear so that
different bindings may apply in different parts of a document.
Processors conforming to this specification must
recognize and act on these declarations and prefixes.
</p>

</div2>

<div2 id='iri-use'>
<head>Use of IRIs as Namespace Names</head>

<p diff="add">
The empty string, though it is a legal IRI
reference, cannot be used as a namespace name.
</p>

<p diff="add">
The use of relative IRI references,
including same-document references, in namespace declarations is
deprecated. Future W3C specifications will define no interpretation
for them.
</p>

</div2>

<div2 diff="add" id='IRIComparison'>
<head>Comparing IRI References</head>
<p>
IRI references identifying namespaces are compared when determining
whether a name belongs to a given namespace, and whether two names
belong to the same namespace.
<termdef id='dt-identical' term='Identical'>
The two IRIs are treated as strings, and they are
<term>identical</term>
if and only if the strings are identical, that is, if they
are the same sequence of characters.  
</termdef>
The comparison is case-sensitive, and no %-escaping is done or undone.
</p>

<p>
A consequence of this is that IRI references which are not identical
in this sense may resolve to the same resource.  Examples include
IRI references which differ only in case or %-escaping, or which are
in external entities which have different base URIs (but note that
relative IRIs are deprecated as namespace names).
</p>

<p>
In a namespace declaration, the IRI reference is the
<xtermref href="&xmlspec;#AVNormalize">normalized value</xtermref>
of the attribute, so replacement of XML character and entity references
has already been done before any comparison.
</p>

<p>Examples:</p>

<p>
The IRI references below are all different for the purposes of identifying
namespaces, since they differ in case:
</p>

<ulist>
<item><p><code>
http://www.example.org/wine
</code></p></item>
<item><p><code>
http://www.Example.org/wine
</code></p></item>
<item><p><code>
http://www.example.org/Wine
</code></p></item>
</ulist>

<p>
The IRI references below are also all different for the purposes of identifying
namespaces:
</p>

<ulist>
<item><p><code>
http://www.example.org/ros&#xe9;
</code></p></item>
<item><p><code>
http://www.example.org/ros%c3%a9
</code></p></item>
<item><p><code>
http://www.example.org/ros%c3%A9
</code></p></item>
<item><p><code>
http://www.example.org/ros%C3%a9
</code></p></item>
<item><p><code>
http://www.example.org/ros%C3%A9
</code></p></item>
</ulist>

<p>
As are these:
</p>

<ulist>
<item><p><code>
http://www.example.org/~wilbur
</code></p></item>
<item><p><code>
http://www.example.org/%7ewilbur
</code></p></item>
<item><p><code>
http://www.example.org/%7Ewilbur
</code></p></item>
</ulist>

<p>
If the entity <kw>eacute</kw> has been defined to be <kw>&#xe9;</kw>,
the start tags below all contain namespace declarations binding
the prefix <kw>p</kw>
to the same IRI reference, <code>http://example.org/ros&#xe9;</code>.
</p>

<ulist>
<item><p><code>
<![CDATA[<p:foo xmlns:p="http://example.org/ros]]>&#xe9;"&gt;
</code></p></item>
<item><p><code>
<![CDATA[<p:foo xmlns:p="http://example.org/ros&#xe9;">]]>
</code></p></item>
<item><p><code>
<![CDATA[<p:foo xmlns:p="http://example.org/ros&#xE9;">]]>
</code></p></item>
<item><p><code>
<![CDATA[<p:foo xmlns:p="http://example.org/ros&#233;">]]>
</code></p></item>
<item><p><code>
<![CDATA[<p:foo xmlns:p="http://example.org/ros&eacute;">]]>
</code></p></item>
</ulist>

</div2>

</div1>

<div1 id='ns-decl'> 
<head>Declaring Namespaces</head>
<p><termdef id='dt-NSDecl' term='Namespace declaration'>A namespace
<phrase diff="add">(or more precisely, a namespace binding)</phrase>
is
<term>declared</term> using 
a family of reserved attributes.
Such an attribute's name  must either
be <kw>xmlns</kw> or <phrase diff="chg">begin <kw>xmlns:</kw></phrase>.
These attributes, like any other XML attributes, may be provided
directly or by <xtermref href='&xmlspec;#dt-default'>default</xtermref>.
</termdef>
</p>
<scrap lang='ebnf'>
<head>Attribute Names for Namespace Declaration</head>
<!--
<prod id='NT-AttNSDecl'><lhs>NSDecl</lhs>
<rhs><nt def='NT-NSAttName'>NSAttName</nt>
<xnt href='&xmlspec;#NT-Eq'>Eq</xnt>
<xnt href="&xmlspec;#NT-AttValue">AttValue</xnt></rhs>
<nsc def='nsc-emptyLit' />
</prod> -->
<prod id='NT-NSAttName'><lhs>NSAttName</lhs>
<rhs><nt def='NT-PrefixedAttName'>PrefixedAttName</nt></rhs>
<rhs>| <nt def='NT-DefaultAttName'>DefaultAttName</nt></rhs></prod>
<prod id='NT-PrefixedAttName'><lhs>PrefixedAttName</lhs>
<rhs>'xmlns:' <nt def='NT-NCName'>NCName</nt></rhs>
<nsc def='xmlReserved' />
</prod>
<prod id='NT-DefaultAttName'><lhs>DefaultAttName</lhs>
<rhs>'xmlns'</rhs></prod>
<prod id='NT-NCName' diff="chg"><lhs>NCName</lhs>
<rhs><nt def='NT-NCNameStartChar'>NCNameStartChar</nt>
<nt def='NT-NCNameChar'>NCNameChar</nt>*</rhs><com>An XML
<xnt href='&xmlspec;#NT-Name'>Name</xnt>, minus the ":"</com></prod>
<prod id='NT-NCNameChar' diff="chg"><lhs>NCNameChar</lhs>
<rhs><xnt href="&xml11spec;#NT-NameChar">NameChar</xnt>
- ':'</rhs>
</prod>
<prod id='NT-NCNameStartChar' diff="add"><lhs>NCNameStartChar</lhs>
<rhs><xnt href="&xml11spec;#NT-NameStartChar">NameStartChar</xnt>
- ':'</rhs>
</prod>
</scrap>

<p>
<phrase diff="chg">
The attribute's
<xtermref href="&xmlspec;#AVNormalize">normalized value</xtermref>
must be either an IRI reference &mdash; the 
<termref def='dt-NSName'>namespace name</termref>
identifying the namespace &mdash;
or an empty string.
</phrase>
The namespace name, to serve its
intended purpose, should have the characteristics of uniqueness and
persistence.
It is not a goal that it be directly usable for retrieval of a schema (if
any exists). 
An example of a syntax that is designed with these goals in mind is
that for Uniform Resource Names <bibref ref='URNs'/>.
However, it should be noted that ordinary URLs can be managed in such a way as
to achieve these same goals.</p>

<p>
<termdef id='dt-prefix' term='Namespace Prefix'>If the
attribute name matches <nt def='NT-PrefixedAttName'>PrefixedAttName</nt>,
then the
<nt def="NT-NCName">NCName</nt> gives the <term>namespace prefix</term>,
used to associate element and attribute names with the
<termref def='dt-NSName'>namespace name</termref> in the attribute value
in the scope of the element to which the declaration
is attached.</termdef>
<phrase diff="del">The attribute value may be an empty string</phrase>.
</p>

<p><termdef id='dt-defaultNS' term='Default Namespace'>If the 
attribute name matches <nt def='NT-DefaultAttName'>DefaultAttName</nt>,
then the
<termref def='dt-NSName'>namespace name</termref> in the
attribute value is
that of the <term>default namespace</term>
in the scope of the element to which the declaration
is attached.</termdef>
<phrase diff="del">The attribute value may be an empty string</phrase>.
Default namespaces and overriding of declarations are discussed in 
<specref ref='scoping-defaulting'/>.
</p>


<p>An example namespace declaration, which associates the 
namespace prefix <kw>edi</kw> with the namespace name 
<code>http://ecommerce.org/schema</code>:
</p>
<eg><![CDATA[<x xmlns:edi='http://ecommerce.org/schema'>
  <!-- the "edi" prefix is bound to http://ecommerce.org/schema
       for the "x" element and contents -->
</x>]]></eg>



<nscnote id='xmlReserved' diff="chg">
<head>Reserved Prefixes and Namespace Names</head>

<p>
The prefix <kw>xml</kw> is by definition bound to the namespace name
<code>http://www.w3.org/XML/1998/namespace</code>. It may, but need not, be
declared, and must not be bound to any other namespace name. No other
prefix may be bound to this namespace name.
</p>

<p>
The prefix <kw>xmlns</kw> is used only to declare namespace bindings and is by
definition bound to the namespace name
<code>http://www.w3.org/2000/xmlns/</code>. It must not be declared. No other
prefix may be bound to this namespace name.
</p>

<p>
All other prefixes beginning with the three-letter sequence x, m, l,
in any case combination, are reserved. This means that:
</p>

<ulist>
 <item>
  <p>users should not use them except as defined by later specifications</p>
 </item>
 <item>
  <p>processors must not treat them as fatal errors.</p>
 </item>
</ulist>

</nscnote>

<p diff="add">
Though they are not themselves reserved, it is inadvisable to use
prefixed names whose LocalPart begins with the letters x, m, l, in any
case combination, as
these names would be reserved if used without a prefix.
</p>

</div1>
<div1 id='ns-qualnames'>
<head>Qualified Names</head>
<p>In XML
documents conforming to this specification, some
names (constructs corresponding to the nonterminal 
<xnt href="&xml11spec;#NT-Name">Name</xnt>)
<phrase diff="chg">must be</phrase> given as
<termref def='dt-qualname'>qualified names</termref>,
defined as follows:
</p>
<scrap lang='ebnf'>
<head>Qualified Name</head>

<prod diff="chg" id='NT-QName'><lhs>QName</lhs>
<rhs><nt def='NT-PrefixedName'>PrefixedName</nt></rhs>
<rhs>| <nt def='NT-UnprefixedName'>UnprefixedName</nt></rhs>
</prod>

<prod diff="add" id='NT-PrefixedName'><lhs>PrefixedName</lhs>
<rhs>
<nt def='NT-Prefix'>Prefix</nt> ':' <nt def='NT-LocalPart'>LocalPart</nt>
</rhs>
</prod>

<prod diff="add" id='NT-UnprefixedName'><lhs>UnprefixedName</lhs>
<rhs>
<nt def='NT-LocalPart'>LocalPart</nt>
</rhs>
</prod>

<prod id='NT-Prefix'><lhs>Prefix</lhs>
<rhs><nt def="NT-NCName">NCName</nt></rhs></prod>
<prod id='NT-LocalPart'><lhs>LocalPart</lhs>
<rhs><nt def="NT-NCName">NCName</nt></rhs>
</prod>

</scrap>
<p>
The 
<nt def='NT-Prefix'>Prefix</nt> provides the 
<termref def='dt-prefix'>namespace prefix</termref>
part of the qualified name, and must be associated with a namespace <phrase diff="chg">IRI</phrase>
reference in a
<termref def='dt-NSDecl'>namespace declaration</termref>.
<termdef id='dt-localpart' term='Local Part'>
The <nt def='NT-LocalPart'>LocalPart</nt> provides the
<term>local part</term> of the qualified name.</termdef>
</p>
<p>Note that the prefix functions <emph>only</emph> as a placeholder for a
namespace name.
Applications should use the namespace name, not the prefix, in constructing
names whose scope extends beyond the 
containing document.</p>
</div1>
<div1 id='ns-using'>
<head>Using Qualified Names</head>
<p>In XML documents conforming to this specification,
element <phrase diff="chg">names</phrase> are given as
<termref def='dt-qualname'>qualified names</termref>, as
follows:
</p>
<scrap lang='ebnf'>
<head diff="chg">Element Names</head>
<prod id='NT-STag'><lhs>STag</lhs>
<rhs>'&lt;' <nt def='NT-QName'>QName</nt> 
(<xnt href='&xmlspec;#NT-S'>S</xnt> 
<xnt href='&xmlspec;#NT-Attribute'>Attribute</xnt>)* 
<xnt href='&xmlspec;#NT-S'>S</xnt>? '>'
</rhs><nsc def='nsc-NSDeclared'/>
</prod>
<prod id='NT-ETag'><lhs>ETag</lhs>
<rhs>'&lt;/' <nt def='NT-QName'>QName</nt> 
<xnt href='&xmlspec;#NT-S'>S</xnt>? '>'</rhs>
<nsc def='nsc-NSDeclared'/></prod>
<prod id='NT-EmptyElemTag'><lhs>EmptyElemTag</lhs>
<rhs>'&lt;' <nt def='NT-QName'>QName</nt> 
(<xnt href='&xmlspec;#NT-S'>S</xnt>
<xnt href='&xmlspec;#NT-Attribute'>Attribute</xnt>)* 
<xnt href='&xmlspec;#NT-S'>S</xnt>? '/>'</rhs>
<nsc def='nsc-NSDeclared'/></prod>
</scrap>
<p>An example of a qualified name serving as an element name:
</p>
<eg diff="chg"><![CDATA[
  <!-- the 'price' element's namespace is http://ecommerce.org/schema -->
  <edi:price xmlns:edi='http://ecommerce.org/schema' units='Euro'>32.18</edi:price>
]]></eg>

<p>
Attributes are either <termref def='dt-NSDecl'>namespace
declarations</termref>
or their names are given as
<termref def='dt-qualname'>qualified names</termref>:
</p>
<scrap lang='ebnf'>
<head>Attribute</head>
<prod id='NT-Attribute'><lhs>Attribute</lhs>
<rhs><nt def='NT-NSAttName'>NSAttName</nt>
<xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
<xnt href='&xmlspec;#NT-AttValue'>AttValue</xnt></rhs>
<rhs>| <nt def='NT-QName'>QName</nt> <xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
<xnt href='&xmlspec;#NT-AttValue'>AttValue</xnt></rhs>
<nsc def='nsc-NSDeclared'/></prod>
</scrap>
<p>An example of a qualified name serving as an attribute name:
</p>
<eg><![CDATA[<x xmlns:edi='http://ecommerce.org/schema'>
  <!-- the 'taxClass' attribute's namespace is http://ecommerce.org/schema -->
  <lineItem edi:taxClass="exempt">Baby food</lineItem>
</x>]]></eg>
<nscnote diff="chg" id='nsc-NSDeclared'>
<head>Prefix Declared</head>
<p>The namespace prefix, unless it is <code>xml</code>
or <code>xmlns</code>, must have been
declared in a <termref def='dt-NSDecl'>namespace declaration</termref>
attribute in either the start-tag of the element where the prefix 
is used or in an ancestor element (i.e. an element in whose 
<xtermref href='&xmlspec;#dt-content'>content</xtermref> the
prefixed markup occurs).
Furthermore, the attribute value in the innermost such declaration 
must not be <phrase diff="chg">an empty string</phrase>.
</p></nscnote>
<p>This constraint may lead to operational difficulties in the case where
the namespace declaration attribute is provided, not directly in the XML
<xtermref href='&xmlspec;#dt-docent'>document entity</xtermref>, but 
via a default attribute declared in an external entity.
Such declarations may not be read by software which is based on a
non-validating XML processor.
Many XML applications, presumably including namespace-sensitive ones, fail to
require validating processors.
<phrase diff="chg">If correct operation with such applications is required</phrase>,
namespace declarations must be
provided either directly or via default attributes declared in the
<xtermref href='&xmlspec;#dt-doctype'>internal subset of the DTD</xtermref>.
</p>
<p>Element names and attribute <phrase diff="chg">names</phrase> are also given as qualified names when
they appear in declarations in the 
<xtermref href='&xmlspec;#dt-doctype'>DTD</xtermref>:
</p>
<scrap lang='ebnf'>
<head>Qualified Names in Declarations</head>
<prod id='NT-doctypedecl'><lhs>doctypedecl</lhs>
<rhs>'&lt;!DOCTYPE' <xnt href='&xmlspec;#NT-S'>S</xnt>
<nt def='NT-QName'>QName</nt> (<xnt href='&xmlspec;#NT-S'>S</xnt>
<xnt href='&xmlspec;#NT-ExternalID'>ExternalID</xnt>)? 
<xnt href='&xmlspec;#NT-S'>S</xnt>? ('[' 
(<xnt href='&xmlspec;#NT-markupdecl'>markupdecl</xnt> 
| <xnt href='&xmlspec;#NT-PEReference'>PEReference</xnt> 
| <xnt href='&xmlspec;#NT-S'>S</xnt>)* 
']' 
<xnt href='&xmlspec;#NT-S'>S</xnt>?)? '>'</rhs>
</prod>

<prod id='NT-elementdecl'><lhs>elementdecl</lhs>
<rhs>'&lt;!ELEMENT' <xnt href='&xmlspec;#NT-S'>S</xnt> 
<nt def='NT-QName'>QName</nt> 
<xnt href='&xmlspec;#NT-S'>S</xnt> 
<xnt href='&xmlspec;#NT-contentspec'>contentspec</xnt>
<xnt href='&xmlspec;#NT-S'>S</xnt>? '>'</rhs>
</prod>
<prod id='NT-cp'><lhs>cp</lhs>
<rhs>(<nt def='NT-QName'>QName</nt> 
| <xnt href='&xmlspec;#NT-choice'>choice</xnt> 
| <xnt href='&xmlspec;#NT-seq'>seq</xnt>) 
('?' | '*' | '+')?</rhs></prod>
<prod id='NT-Mixed'><lhs>Mixed</lhs>
<rhs>'(' <xnt href='&xmlspec;#NT-S'>S</xnt>? 
'#PCDATA'
(<xnt href='&xmlspec;#NT-S'>S</xnt>? 
'|' 
<xnt href='&xmlspec;#NT-S'>S</xnt>? 
<nt def='NT-QName'>QName</nt>)* 
<xnt href='&xmlspec;#NT-S'>S</xnt>? 
')*' </rhs>
<rhs>| '(' <xnt href='&xmlspec;#NT-S'>S</xnt>? '#PCDATA' <xnt href='&xmlspec;#NT-S'>S</xnt>? ')'
</rhs>
</prod>
<prod id='NT-AttlistDecl'><lhs>AttlistDecl</lhs>
<rhs>'&lt;!ATTLIST' <xnt href='&xmlspec;#NT-S'>S</xnt> 
<nt def='NT-QName'>QName</nt> 
<nt def='NT-AttDef'>AttDef</nt>*
<xnt href='&xmlspec;#NT-S'>S</xnt>? '&gt;'</rhs>
</prod>
<prod id='NT-AttDef'><lhs>AttDef</lhs>
<rhs><xnt href='&xmlspec;#NT-S'>S</xnt> 
(<nt def='NT-QName'>QName</nt> | <nt def='NT-NSAttName'>NSAttName</nt>)
<xnt href='&xmlspec;#NT-S'>S</xnt> <xnt href='&xmlspec;#NT-AttType'>AttType</xnt> 
<xnt href='&xmlspec;#NT-S'>S</xnt> <xnt href='&xmlspec;#NT-DefaultDecl'>DefaultDecl</xnt></rhs>
</prod>
</scrap>

<p diff="add">
Note that DTD-based validation is not namespace-aware; no mechanism is
provided for binding or defaulting namespaces within a DTD, and
element and attribute names in declarations are matched literally
against names in the instance.  To validate a document that uses
namespaces against a DTD, the same prefixes must be used in the DTD as
in the instance.
</p>

</div1>

<div1 id='scoping-defaulting'>
<head>Applying Namespaces to Elements and Attributes</head>
<div2 id='scoping'>
<head>Namespace Scoping</head>

<p diff="chg">
The scope of a namespace declaration declaring a prefix extends from
the beginning of the start-tag in which it appears to the end of the
corresponding end-tag, excluding the scope of any inner declarations
with the same NSAttName part.
In the case of an empty tag, the scope is the tag itself.
</p>

<p diff="chg">
Such a namespace declaration applies to to all element and attribute
names within its scope whose prefix matches that specified in the
declaration.
</p>

<p diff="add">
The
<termref def='dt-expname'>expanded name</termref>
corresponding to a prefixed element or attribute name has the
IRI to which the
<termref def='NT-Prefix'>prefix</termref>
is bound as its
<termref def='dt-NSName'>namespace name</termref>,
and the
<termref def='NT-LocalPart'>local part</termref>
as its
<termref def='dt-localname'>local name</termref>.
</p>

<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
<!-- all elements here are explicitly in the HTML namespace -->
&lt;html:html xmlns:html='<phrase diff="chg">http://www.w3.org/1999/xhtml</phrase>'&gt;
<![CDATA[
  <html:head><html:title>Frobnostication</html:title></html:head>
  <html:body><html:p>Moved to 
    <html:a href='http://frob.com'>here.</html:a></html:p></html:body>
</html:html>]]></eg>
<p>Multiple namespace prefixes can be declared as attributes of a single element, 
as shown in this example:
</p>
<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
<![CDATA[<!-- both namespace prefixes are available throughout -->
<bk:book xmlns:bk='urn:loc.gov:books'
         xmlns:isbn='urn:ISBN:0-395-36341-6'>
    <bk:title>Cheaper by the Dozen</bk:title>
    <isbn:number>1568491379</isbn:number>
</bk:book>]]></eg>
<p diff="add">
The attribute value in a namespace declaration for a prefix may be empty.
This has the effect, within the scope of the declaration, of removing
any association of the prefix with a namespace name.  Further declarations
may re-declare the prefix again:
</p>
<eg diff="add">
<phrase diff="add">
&lt;?xml version="1.1"?>
<![CDATA[<x xmlns:n1="http://www.w3.org">
    <n1:a/>               <!-- legal; the prefix n1 is bound to http://www.w3.org -->
    <x xmlns:n1="">
        <n1:a/>           <!-- illegal; the prefix n1 is not bound here -->
	<x xmlns:n1="http://www.w3.org">
            <n1:a/>       <!-- legal; the prefix n1 is bound again -->
        </x>
    </x>
</x>]]></phrase></eg>
</div2>
<div2 id='defaulting'>
<head>Namespace Defaulting</head>

<p diff="chg">
The scope of a
<termref def='dt-defaultNS'>default namespace</termref> declaration
extends from the beginning of the
start-tag in which it appears to the end of the corresponding end-tag,
excluding the scope of any inner default namespace declarations.
In the case of an empty tag, the scope is the tag itself.
</p>

<p diff="chg">
A default namespace declaration applies to to all unprefixed element names
within its scope.
Default namespace declarations do not apply directly to attribute names;
the interpretation of unprefixed attributes is
determined by the element on which they appear.
</p>

<p diff="add">
If there is a default namespace declaration in scope, the
<termref def='dt-expname'>expanded name</termref>
corresponding to an unprefixed element name has the
IRI of the
<termref def='dt-defaultNS'>default namespace</termref>
as its
<termref def='dt-NSName'>namespace name</termref>.
If there is no default namespace declaration in scope, the
namespace name is null.
The namespace name for an unprefixed attribute name is always null.
In all cases, the
<termref def='dt-localname'>local name</termref> is
<termref def='NT-LocalPart'>local part</termref>
(which is of course the same as the unprefixed name itself).
</p>

<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
&lt;!-- elements are in the HTML namespace, in this case by default --&gt;
&lt;html xmlns='<phrase diff="chg">http://www.w3.org/1999/xhtml</phrase>'&gt;
<![CDATA[  <head><title>Frobnostication</title></head>
  <body><p>Moved to 
    <a href='http://frob.com'>here</a>.</p></body>
</html>]]></eg>
<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
<![CDATA[<!-- unprefixed element types are from "books" -->
<book xmlns='urn:loc.gov:books'
      xmlns:isbn='urn:ISBN:0-395-36341-6'>
    <title>Cheaper by the Dozen</title>
    <isbn:number>1568491379</isbn:number>
</book>]]></eg>
<p>A larger example of namespace scoping:
</p>
<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
<![CDATA[<!-- initially, the default namespace is "books" -->
<book xmlns='urn:loc.gov:books'
      xmlns:isbn='urn:ISBN:0-395-36341-6'>
    <title>Cheaper by the Dozen</title>
    <isbn:number>1568491379</isbn:number>
    <notes>
      <!-- make HTML the default namespace for some commentary -->]]>
      &lt;p xmlns='<phrase diff="chg">http://www.w3.org/1999/xhtml</phrase>'&gt;
<![CDATA[          This is a <i>funny</i> book!
      </p>
    </notes>
</book>]]></eg>
<p>The default namespace can be set to the empty string.  
This has the same
effect, within the scope of the declaration, of there being no default
namespace.
</p>
<eg>&lt;?xml version='<phrase diff="chg">1.1</phrase>'?>
&lt;Beers&gt;
  &lt;!-- <phrase diff="chg">the default namespace inside tables is that of HTML</phrase> --&gt;
  &lt;table xmlns='<phrase diff="chg">http://www.w3.org/1999/xhtml</phrase>'&gt;
<![CDATA[   <th><td>Name</td><td>Origin</td><td>Description</td></th>
   <tr> 
     <!-- no default namespace inside table cells -->
     <td><brandName xmlns="">Huntsman</brandName></td>
     <td><origin xmlns="">Bath, UK</origin></td>
     <td>
       <details xmlns=""><class>Bitter</class><hop>Fuggles</hop>
         <pro>Wonderful hop, light alcohol, good summer beer</pro>
         <con>Fragile; excessive variance pub to pub</con>
         </details>
        </td>
      </tr>
    </table>
  </Beers>]]></eg>
</div2>
<div2 id='uniqAttrs'>
<head>Uniqueness of Attributes</head>
<p>In XML documents conforming
to this specification, no tag
may contain two attributes which:
</p>
<olist><item><p>have identical names, or</p></item>
<item><p>have qualified names with the same
<termref def='dt-localpart'>local part</termref> and with 
<termref def='dt-prefix'>prefixes</termref> which have been bound
to <termref def='dt-NSName'>namespace names</termref> that
are <termref def='dt-identical'>identical</termref>.
</p>
</item>
</olist>
<p diff="add">
This constraint is equivalent to requiring that no element have two
attributes with the same 
<termref def='dt-expname'>expanded name</termref>.
</p>
<p>For example, each of the <code>bad</code> start-tags is illegal in the
following:
</p>
<eg><![CDATA[<!-- http://www.w3.org is bound to n1 and n2 -->
<x xmlns:n1="http://www.w3.org" 
   xmlns:n2="http://www.w3.org" >
  <bad a="1"     a="2" />
  <bad n1:a="1"  n2:a="2" />
</x>]]></eg>
<p>
However, each of the following is legal, the second because the default 
namespace does not apply to attribute names:
</p>
<eg><![CDATA[<!-- http://www.w3.org is bound to n1 and is the default -->
<x xmlns:n1="http://www.w3.org" 
   xmlns="http://www.w3.org" >
  <good a="1"     b="2" />
  <good a="1"     n1:a="2" />
</x>]]></eg>
</div2>
</div1>

<div1 diff="chg" id='Conformance'>
<head>Conformance of Documents</head>

<p>
This specification applies to XML 1.1 documents. To conform to this
specification, a document must be well-formed according to the XML 1.1
specification.
</p>

<p>

In XML documents which conform to this specification, element
and attribute names must match the production for 
<nt def='NT-QName'>QName</nt>
and must satisfy the "Namespace Constraints". All other tokens in the
document which are required, for XML 1.1 well-formedness, to match the
XML production for 
<xnt href="&xml11spec;#NT-Name">Name</xnt>,
must match this specification's production for 
<nt def='NT-NCName'>NCName</nt>.
</p>

<p>
<termdef id='dt-nwf' term='namespace well-formedness'>
A document is <term>namespace-well-formed</term> 
if it conforms to this specification.
</termdef>
</p>

<p>
It follows that in a namespace-well-formed document:
</p>

<ulist>
 <item>
  <p>All element and attribute names contain either zero or one 
  colon;</p>
 </item>
 <item>
  <p>No entity names, PI targets, or notation names contain any colons.</p>
 </item>
</ulist>

<p>
In addition, a namespace-well-formed document may also be namespace-valid.
</p>

<p>
<termdef id='dt-nv' term='namespace validity'>
A namespace-well-formed document is <term>namespace-valid</term>
if it is valid according to the XML 1.1 specification, and all tokens
other than element and attribute names which are required, for
XML 1.1 validity, to match the XML production for
<xnt href="&xml11spec;#NT-Name">Name</xnt>,
match this specification's production for
<nt def='NT-NCName'>NCName</nt>.
</termdef>
</p>

<p>
It follows that in a namespace-valid document:
</p>

<ulist>
 <item>
  <p>
   No attributes with a declared type of
   <kw>ID</kw>, <kw>IDREF(S)</kw>, <kw>ENTITY(IES)</kw>, or <kw>NOTATION</kw>
   contain any colons.
  </p>
 </item>
</ulist>

</div1>

<div1 diff="add" id='ProcessorConformance'>
<head>Conformance of Processors</head>

<p>
To conform to this specification, a processor must report
violations of namespace well-formedness, with the exception that it
it not required to check that namespace names are legal IRIs.
</p>
<p>
<termdef id='dt-nvp' term='namespace-validating'>
A validating XML processor that conforms to this specification
is <term>namespace-validating</term> if in addition
it reports violations of namespace validity.
</termdef>
</p>

</div1>

<div1 diff="add" id="IRIs">
<head>Internationalized Resource Identifiers (IRIs)</head>

<p>
Work is currently in progress to produce an RFC defining
Internationalized Resource Identifiers (IRIs).  Since this work is not
yet complete, in this section we give a syntactic definition of IRIs
for the purposes of this specification.  We expect to issue an erratum
replacing this section with a reference to the RFC when it is
published.  Users defining namespaces are advised to restrict namespace
names to URIs until software supporting IRIs is in common use.
</p>

<p>
For a more general definition and discussion of IRIs see <bibref ref='IRIdraft'/>
(work in progress).
</p>

<p>
URI references are restricted to a subset of the ASCII characters;
IRI references allow some of the disallowed ASCII characters as well
as most Unicode characters from #xA0 onwards.
</p>

<p>
<termdef id='dt-addchar' term='additional characters'>
The <term>additional characters</term> allowed in IRIs are:
</termdef>
</p>

<ulist>
<item><p>
space #x20
</p></item>
<item><p>
the delimiters <kw>&lt;</kw> #x3C, <kw>&gt;</kw> #x3E and <kw>"</kw> #x22
</p></item>
<item><p>
the unwise characters <kw>{</kw> #x7B, <kw>}</kw> #x7D, <kw>|</kw> #x7C,
<kw>\</kw> #x5C, <kw>^</kw> #x5E and <kw>`</kw> #x60
</p></item>
<item><p>
the Unicode plane 0 characters #xA0 - #xD7FF, #xF900-#xFDCF, #xFDF0-#xFFEF
</p></item>
<item><p>
the Unicode plane 1-14 characters #x10000-#x1FFFD ... #xE000-#xEFFD
</p></item>
</ulist>

<p>
<termdef id='dt-IRI' term='IRI reference'>
An <term>IRI reference</term> is a string that can be converted to
a URI reference by escaping all additional characters as follows:
</termdef>
</p>

<olist>
 <item>
  <p>
   Each additional character is converted to UTF-8
   <bibref ref="Unicode32"/>
   as one or more bytes.
  </p>
 </item>
 <item>
  <p>
   The resulting bytes are escaped with
   the URI escaping mechanism (that is, converted to %HH, where HH is
   the hexadecimal notation of the byte value).
  </p>
 </item>
 <item>
  <p>
   The original character is replaced by the resulting character sequence.
  </p>
 </item>
</olist>

</div1>

<div1 diff="add" id="XML11">
<head>XML 1.1 Productions</head>

<p>
This section will not be present in the final version of this
specification.  It contains productions that will appear in
the XML 1.1 specification and are different from those in
XML 1.0.
</p>

<scrap lang='ebnf'>
<head>XML 1.1 Productions</head>

<prod id='NT-Name'><lhs>Name</lhs>
<rhs><nt def="NT-NameStartChar">NameStartChar</nt>
<nt def="NT-NameChar">NameChar</nt>*</rhs>
</prod>

<prod id='NT-NameChar'><lhs>NameChar</lhs>
<rhs/><com>To be defined in XML 1.1</com>
</prod>

<prod id='NT-NameStartChar'><lhs>NameStartChar</lhs>
<rhs/><com>To be defined in XML 1.1</com>
</prod>

</scrap>

</div1>

</body>
<back>
<div1 id='refs'>
<head>References</head>
<blist>

<bibl diff="add" id="IRIdraft" key='IRI draft'>
<titleref>Internationalized Resource Identifiers (IRIs)</titleref>.
Available at <loc href="http://www.w3.org/International/iri-edit/draft-duerst-iri-02.txt">
http://www.w3.org/International/iri-edit/draft-duerst-iri-02.txt</loc>
</bibl>

<bibl diff="add" id="errata10" key='1.0 Errata'>
<titleref>Namespaces in XML Errata</titleref>.
Available at <loc href="http://www.w3.org/XML/xml-names-19990114-errata">
http://www.w3.org/XML/xml-names-19990114-errata</loc>
</bibl>

<bibl diff="add" id="req11" key="Requirements">
<titleref>Namespaces in XML 1.1 Requirements</titleref>,
ed. Jonathan Marsh.  March 2002.
Available at
<loc href="http://www.w3.org/TR/2002/WD-xml-names11-req-20020403/">http://www.w3.org/TR/2002/WD-xml-names11-req-20020403/</loc>
</bibl>

<bibl id='URNs' key='RFC2141'>
IETF (Internet Engineering Task Force)
<titleref>RFC 2141: URN Syntax</titleref>, ed. R. Moats. May 1997.
<phrase diff="add">
Available at
<loc href="ftp://ftp.ietf.org/rfc/rfc2141.txt">ftp://ftp.ietf.org/rfc/rfc2141.txt</loc>
</phrase>
</bibl>

<!--
<bibl diff="add" id='UTF8' key='RFC2279'>
IETF (Internet Engineering Task Force)
<titleref>RFC 2279: UTF-8, a transformation format of ISO 10646</titleref>,
ed. F. Yergeau.
January 1998.
Available at <loc href="http://www.ietf.org/rfc/rfc2279.txt">http://www.ietf.org/rfc/rfc2279.txt</loc>
</bibl>
-->

<bibl id='URIRef' key='RFC2396'>
IETF (Internet Engineering Task Force)
<titleref>RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax</titleref>,
eds. T. Berners-Lee, R. Fielding, L. Masinter.  
August 1998.
<phrase diff="add">
Available at
<loc href="ftp://ftp.ietf.org/rfc/rfc2396.txt">ftp://ftp.ietf.org/rfc/rfc2396.txt</loc>
</phrase>
</bibl>

<bibl diff="add" id='IP6URL' key='RFC2732'>
IETF (Internet Engineering Task Force)
<titleref>RFC 2732: Format for Literal IPv6 Addresses in URL's</titleref>,
eds. R. Hinden, B. Carpenter, L. Masinter.
December 1999.
Available at <loc href="http://www.ietf.org/rfc/rfc2732.txt">http://www.ietf.org/rfc/rfc2732.txt</loc>
</bibl>

<!--
<bibl id='IRIRef' key='IRI-draft' diff="add">
IETF (Internet Engineering Task Force) Internet Draft
<titleref>Internationalized Resource Identifiers (IRI), draft-duerst-iri-01</titleref>,
M. Duerst, M. Suignard.
July 1 2002.
Available at
<loc href="http://www.w3.org/International/2002/draft-duerst-iri-01.txt">http://www.w3.org/International/2002/draft-duerst-iri-01.txt</loc>
</bibl>
-->

<bibl id="Unicode32" key="Unicode 3.2" diff="add">
The Unicode Consortium
<titleref>The Unicode Standard, Version 3.2.0</titleref>
is defined by 
<titleref>The Unicode Standard, Version 3.0</titleref>
(Reading, MA, Addison-Wesley, 2000. ISBN 0-201-61633-5),
as amended by the 
<titleref>Unicode Standard Annex #27: Unicode 3.1</titleref>
(see <loc href="http://www.unicode.org/reports/tr27/">
http://www.unicode.org/reports/tr27</loc>) 
and by the
<titleref>Unicode Standard Annex #28: Unicode 3.2</titleref>
(<loc href="http://www.unicode.org/reports/tr28/">
http://www.unicode.org/reports/tr28</loc>).
</bibl>

<bibl diff="chg" id='XML' key='XML'>
<titleref>Extensible Markup Language
(XML) 1.0 (Second Edition)</titleref>, eds. Tim Bray, Jean
Paoli, C. M. Sperberg-McQueen, and Eve Maler.
6 October 2000. Available at
<loc href="&xmlspec;">&xmlspec;</loc>.
</bibl>

<bibl diff="add" id='XML11CR' key='XML 1.1 CR draft'>
<titleref>Extensible Markup Language
(XML) 1.1</titleref>,
<!-- eds. Tim Bray, Jean
Paoli, C. M. Sperberg-McQueen, Eve Maler, and John Cowan. -->
ed. John Cowan 15 October 2002.
Available at
<loc href="http://www.w3.org/TR/2002/CR-xml11-20021015/">http://www.w3.org/TR/2002/CR-xml11-20021015/</loc>.
</bibl>

</blist>
</div1>

<inform-div1 id='Philosophy'>
<head>The Internal Structure of XML Namespaces</head>
<p diff="chg">
This appendix has been deleted.
</p>
</inform-div1>

<inform-div1 diff="add" id="changes">

<head>Changes since version 1.0</head>

<p>
This version incorporates the errata to version 1.0 as of 6 December 2002
<bibref ref="errata10"/>.  There are two further substantive changes:
</p>

<ulist>
<item>
<p>A mechanism is provided for undeclaring prefixes;</p>
</item>
<item>
<p>Namespace names are IRIs, rather than URIs.</p>
</item>
</ulist>

<p>
There are several editorial changes, including a number
of terminology changes and additions intended to produce greater
consistency.  The non-normative appendix "The Internal Structure 
of XML Namespaces" has been removed.
</p>

</inform-div1>

<inform-div1 id='sec-xml-and-sgml'>
<head>Acknowledgements</head>

<p>This work reflects input from a very large number of people, 
including especially the members of the World Wide
Web Consortium XML Working Group and Special Interest Group 
and the participants in the W3C Metadata Activity.
The contributions of Charles Frankston of Microsoft 
were particularly valuable.</p>
</inform-div1>

</back>
</spec>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-default-dtd-file:"~/sgml/spec.ced"
sgml-omittag:t
sgml-shorttag:t
End:
-->
