<?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 "20020905">
 <!ENTITY directory "http://www.w3.org/TR/2002/WD-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="wd">
<header>
<title>Namespaces in XML</title>
<version>1.1</version>
<w3c-designation>xml-names11-&iso6.doc.date;</w3c-designation>
<w3c-doctype>W3C Working Draft</w3c-doctype>
<pubdate diff="chg"><day>5</day><month>September</month><year>2002</year></pubdate>
<publoc>
<loc href="&directory;">
&directory;</loc>
</publoc>
<altlocs>
<loc href="&directory;/WD-xml-names11-&iso6.doc.date;.xml">XML</loc>
<loc href="&directory;/WD-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-20020403/">
http://www.w3.org/TR/2002/WD-xml-names11-20020403/</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>The <loc href="http://www.w3.org/XML/Activity#core-wg">XML Core Working
Group</loc>, with this Namespaces in XML 1.1 <loc href="http://www.w3.org/Consortium/Process-20010208/tr.html#last-call">Last
Call</loc> working draft, invites comment on this specification. The Last
Call period begins 5 September 2002 and ends 28 September 2002.</p>
<p> 
This document is a draft of a new 1.1 revision of the
Namespaces in XML specification.  It incorporates several
errata to the 1.0 specification, and one substantive change: the
provision of a mechanism to "undeclare" prefixes.
Since documents using this new feature will not work with existing
processors, this revision is being tied to the 1.1 revision of XML itself.
XML 1.0 documents must continue to use version 1.0 of this specification.
There is a requirements document for this revision <bibref ref='req11'/>.  
</p>
<p> 
This is a W3C Working Draft for review by W3C Members and other
interested parties.  It has been produced as part of the 
<loc href="http://www.w3.org/XML/Activity">XML Activity</loc>.
It is a draft document and may be updated, replaced or made obsolete
by other documents at any time. It is inappropriate to use W3C Working
Drafts as reference material or to cite them as other than "work in
progress".
</p>
<p>Patent disclosures relevant to this specification may be found on the
Working Group's <loc href="&XMLCore-IPR;">public patent disclosure page</loc>.
</p>
<p> 
This is work in progress and does not imply endorsement by the W3C
membership. A list of current W3C Recommendations and other technical
documents, including Working Drafts and Notes, can be found at
<loc href="http://www.w3.org/TR">http://www.w3.org/TR</loc>.
</p>
<p>Comments and discussion on this document should be sent to 
<loc href='mailto:xml-names-editor@w3.org'>xml-names-editor@w3.org</loc>
(<loc href='http://lists.w3.org/Archives/Public/xml-names-editor/'>public archive</loc>).
</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>
</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 tags 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 type or attribute name.
</p>

<p>These considerations require that document
constructs
should have universal names, 
whose scope extends beyond their
containing document. 
This specification describes a mechanism,
<emph>XML namespaces</emph>, which accomplishes this.</p>

<p><termdef id='dt-namespace' term='Namespace'>An <term>XML namespace</term>
is a collection of names, identified by <phrase diff="chg">an <termref def='dt-IRI'>IRI reference</termref></phrase>,
which are used in XML documents as 
<xtermref href='&xmlspec;#dt-stag'>element types</xtermref> 
and <xtermref href='&xmlspec;#dt-attrname'>attribute names</xtermref>.
</termdef>
XML namespaces
differ from the "namespaces" conventionally used in computing disciplines
in that the XML version has internal structure and is not, mathematically
speaking, a set.
These issues are discussed in
<specref ref='Philosophy' />.
</p>
<p><termdef id='dt-identical' term='Identical'><phrase diff="chg">IRI</phrase> references which
identify namespaces are considered <term>identical</term>
<phrase diff="chg">if and only if</phrase>
they are
exactly the same character-for-character.</termdef>
<phrase diff="add">Case differences and escaping differences (including
case differences in escape sequences) are therefore significant.</phrase>
Note that <phrase diff="chg">IRI</phrase> references which are not identical in this sense may in fact be
functionally equivalent.
Examples include <phrase diff="chg">IRI</phrase> references which differ only in case
<phrase diff="add"> or escaping</phrase>
, or which are in
external entities which have different effective base URIs.
</p>

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

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

<p>Names from XML namespaces may appear as
<termref def='dt-qname'>qualified names</termref>, 
which <phrase diff="add">may</phrase>
contain a single colon separating the name into a
<termref def='dt-prefix'>namespace prefix</termref> and a
<termref def='dt-localname'>local part</termref>.
The prefix, which is mapped to <phrase diff="chg">an IRI</phrase> reference, selects a namespace. 
The combination of
the universally managed <phrase diff="chg">IRI</phrase> namespace and the document's own namespace
produces identifiers that are universally unique.
Mechanisms are provided for prefix scoping and defaulting.
</p>

<p><phrase diff="chg">IRI</phrase> references can contain characters not allowed in names, so cannot
be used directly as namespace prefixes.
Therefore, the 
namespace prefix serves as a proxy for <phrase diff="chg">an IRI</phrase> reference.
An attribute-based syntax described below is used
to <termref def='dt-NSDecl'>declare</termref> the association of the 
namespace prefix with <phrase diff="chg">an IRI</phrase> reference; 
software which supports this namespace proposal must
recognize and act on these declarations and prefixes.
</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 id='ns-decl'> 
<head>Declaring Namespaces</head>
<p><termdef id='dt-NSDecl' term='Namespace declaration'>A namespace is
<term>declared</term> using 
a family of reserved attributes.
Such an attribute's name  must either
be <kw>xmlns</kw> or have <kw>xmlns:</kw> as a prefix.
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>
<termdef id='dt-NSName' term="Namespace name">The attribute's 
<xtermref href="&xmlspec;#dt-attrval">value</xtermref>,
<phrase diff="chg">an IRI</phrase> reference,
is the <term>namespace name</term> identifying the namespace.</termdef>
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="chg">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="chg">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 xml is by definition bound to the namespace name
http://www.w3.org/XML/1998/namespace. 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 xmlns is used only to declare namespace bindings and is by
definition bound to the namespace name
http://www.w3.org/2000/xmlns/. 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, as
these names would be reserved if used without a prefix.
</p>

</div1>
<div1 id='ns-qualnames'>
<head>Qualified Names</head>
<p><termdef id='dt-qname' term='Qualified Name'>In XML
documents conforming to this specification, some
names (constructs corresponding to the nonterminal 
<xnt href="&xml11spec;#NT-Name">Name</xnt>)
may be given as <term>qualified names</term>, defined as follows:
</termdef></p>
<scrap lang='ebnf'>
<head>Qualified Name</head>
<prod id='NT-QName'><lhs>QName</lhs>
<rhs>
(<nt def='NT-Prefix'>Prefix</nt> ':')?
<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-localname' 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 types are given as
<termref def='dt-qname'>qualified names</termref>, as
follows:
</p>
<scrap lang='ebnf'>
<head>Element Types</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 type:
</p>
<eg><![CDATA[<x xmlns:edi='http://ecommerce.org/schema'>
  <!-- the 'price' element's namespace is http://ecommerce.org/schema -->
  <edi:price units='Euro'>32.18</edi:price>
</x>]]></eg>

<p>
Attributes are either <termref def='dt-NSDecl'>namespace
declarations</termref>
or their names are given as
<termref def='dt-qname'>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 empty.
</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.
For correct operation with such applications, 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 types 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>

</div1>

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

<p diff="chg">
A namespace declaration is considered to apply to the element where it
is specified and its attributes, and to all elements and their
attributes within the content of that element, unless overridden by
another namespace declaration with the same NSAttName part:
</p>

<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
<![CDATA[
<!-- all elements here are explicitly in the HTML namespace -->
<html:html xmlns:html='http://www.w3.org/TR/REC-html40'>
  <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">
A <termref def='dt-defaultNS'>default namespace</termref> declaration
is considered to apply to the element where it is specified, and to
all elements within the content of that element, unless overridden by
another default namespace declaration.
If the <phrase diff="chg">IRI</phrase> reference in a default namespace declaration is empty, then 
unprefixed
elements in the scope of the declaration are not considered to be in 
any namespace.
Note that default namespaces do not apply directly to attributes.
</p>

<eg>&lt;?xml version="<phrase diff="chg">1.1</phrase>"?>
<![CDATA[<!-- elements are in the HTML namespace, in this case by default -->
<html xmlns='http://www.w3.org/TR/REC-html40'>
  <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 -->
      <p xmlns='urn:w3-org-ns:HTML'>
          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>'?>
<![CDATA[<Beers>
  <!-- the default namespace is now that of HTML -->
  <table xmlns='http://www.w3.org/TR/REC-html40'>
   <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-localname'>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>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 types
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 types 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 types 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="IRIs">
<head>Internationalized Resource Identifiers (IRIs)</head>

<p>
Some characters are disallowed in URI references, even if they are
allowed in XML; the disallowed characters, according to 
<bibref ref='URIRef'/> and <bibref ref='IP6URL'/>, are
the control characters #x0 to #x1F and #x7F,
space #x20,
the delimiters '&lt;' #x3C, '&gt;' #x3E and '&quot;' #x22,
the unwise characters '{' #x7B, '}' #x7D, '|' #x7C, '\' #x5C, 
'^' #x5E and '`' #x60,
as well as all characters above #x7F.
</p>

<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 disallowed characters as follows:
</termdef>
</p>

<olist>
 <item>
  <p>
   Each disallowed 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="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="chg" id='XML' key='XML'>
<titleref>Extensible Markup Language
(XML) 1.1</titleref>, eds. Tim Bray, Jean
Paoli, C. M. Sperberg-McQueen, Eve Maler, and John Cowan.
XX XXX 2002. Available at
<loc href="&xmlspec;">&xmlspec;</loc>.
</bibl>
-->

</blist>
</div1>

<inform-div1 id='Philosophy'>
<head>The Internal Structure of XML Namespaces</head>
<div2 id='sets-no-good'>
<head>The Insufficiency of the Traditional Namespace</head>
<p>In the computing disciplines, the term "namespace" conventionally refers to
a <emph>set</emph> of names, i.e. a collection containing no duplicates.
However, treating the names used in XML markup
as such a namespace would greatly impair their usefulness.
The primary use of such names in XML documents is to enable identification 
of logical 
structures in documents by software modules such as query processors,
stylesheet-driven
rendering engines, and schema-driven validators.
Consider the following example:
</p>
<eg><![CDATA[<section><title>Book-Signing Event</title>
<signing>
  <author title="Mr" name="Vikram Seth" />
  <book title="A Suitable Boy" price="$22.95" /></signing>
<signing>
  <author title="Dr" name="Oliver Sacks" />
  <book title="The Island of the Color-Blind" price="$12.95" /></signing>
</section>]]></eg>
<p>
In this example, there are three occurrences of the name <code>title</code>
within markup, and the name alone clearly provides insufficient information
to allow correct processing by a software module.</p>
<p>Another problematic area comes from the use of "global" attributes, as
illustrated by this example, a fragment of an XML document which is to 
be displayed using a CSS stylesheet:
</p>
<eg><![CDATA[<RESERVATION>
 <NAME HTML:CLASS="largeSansSerif">Layman, A</NAME>
 <SEAT CLASS="Y" HTML:CLASS="reallyImportant">33B</SEAT>
 <DEPARTURE>1997-05-24T07:55:00+1</DEPARTURE></RESERVATION>]]></eg>
<p>
In this case, the <code>CLASS</code> attribute, which describes the fare basis
and takes values such as "J", "Y", and "C", is distinct at all semantic levels
from the <code>HTML:CLASS</code> attribute, which 
is used to
simulate syntactic richness in HTML, as a means of overcoming the
limited element repertoire by subclassing.</p>
<p><phrase diff="chg">XML</phrase> does not provide a built-in way to declare "global" attributes;
items such as the HTML <code>CLASS</code> attribute are global only in their
prose description and their interpretation by HTML applications.
However, such attributes, an important distinguishing feature of which is that
their names are unique, are commonly observed to occur in a variety of
applications.</p>
</div2>
<div2 id='ns-breakdown'>
<head>XML Namespace Partitions</head>
<p>In order to support the goal of making both qualified and unqualified names
useful in meeting their intended purpose, we identify the names appearing in
an XML namespace as belonging to one of several disjoint traditional
(i.e. set-structured) namespaces, called namespace partitions.
The partitions are:
<glist>
<gitem><label>The All Element Types Partition</label>
<def><p>All element types in an XML namespace appear in this partition.
Each has a unique <termref def='dt-localname'>local part</termref>; the
combination of the namespace name and the local part uniquely identifies the
element type.</p></def></gitem>
<gitem><label>The Global Attribute Partition</label>
<def><p>This partition contains the names of all attributes which are defined,
in this namespace, to be global.
The only required characteristic of a global attribute is that its name be
unique in the global attribute partition.
This specification makes no
assertions as to the proper usage of such attributes.
The combination of the namespace name and the attribute name uniquely
identifies the global attribute.</p></def></gitem>
<gitem><label>The Per-Element-Type Partitions</label>
<def><p>Each type in the All Element Types Partition has an
associated namespace in which appear the names of the unqualified attributes
that are provided for that element.
This is a traditional namespace because the appearance of duplicate attribute
names on an element is forbidden by <phrase diff="chg">XML</phrase>.
The combination of the attribute name with the element's type and namespace
name uniquely identifies each unqualified attribute.</p></def></gitem>
</glist>
</p>
<p>In XML documents conforming to this specification, the names of 
all qualified (prefixed) attributes are assigned to the global attribute
partition, and the names of all unqualified attributes are assigned to the
appropriate per-element-type partition.</p>
</div2>
<div2 id='ns-expnames'>
<head>Expanded Element Types and Attribute Names</head>
<p>For convenience in specifying rules and in making comparisons, we define an
expanded form, expressed here in XML element syntax, for each element type and
attribute name in an XML document.</p>
<p><termdef id='dt-ExpEType' term="Expanded Element Type">An 
<term>expanded element
type</term> is expressed as an empty XML element of type
<code>ExpEType</code>. 
It has a required <code>type</code> attribute which
gives the type's <nt def='NT-LocalPart'>LocalPart</nt>, and an optional
<code>ns</code> attribute which, if the element is qualified, gives its
<termref def='dt-NSName'>namespace name</termref>.</termdef></p>
<p><termdef id='dt-expaname' term="Expanded Attribute Name">An 
<term>expanded
attribute name</term> is expressed as an empty XML element of type
<code>ExpAName</code>.
It has a required <code>name</code> attribute which gives the name.
If the attribute is global, it has a required <code>ns</code> attribute
which gives the <termref def='dt-NSName'>namespace name</termref>;
otherwise, it has a required attribute <code>eltype</code> which
gives the type of the attached element, and an optional attribute
<code>elns</code> which gives the namespace name, if known, of the
attached element.</termdef></p>
<p>Slight variations on the examples given above will illustrate
the working of expanded element types and attribute names.
The following two fragments are each followed by a table showing
the expansion of the names:
</p>
<eg><![CDATA[<!-- 1 --> <section xmlns='urn:com:books-r-us'>
<!-- 2 -->   <title>Book-Signing Event</title>
<!-- 3 -->   <signing>
<!-- 4 -->     <author title="Mr" name="Vikram Seth" />
<!-- 5 -->     <book title="A Suitable Boy" price="$22.95" />
             </signing>
           </section>]]></eg>
<p>
The names would expand as follows:
</p>
<table border="1" cellpadding="7"><tbody>
<tr align='left'><td>Line</td><td>Name</td><td>Expanded</td>
</tr>
<tr>
<td>1</td><td>section</td>
<td>&lt;ExpEType type="section" ns="urn:com:books-r-us" /> </td></tr>
<tr><td>2</td>
<td>title</td><td>&lt;ExpEType type="title" ns="urn:com:books-r-us" /> </td>
</tr>
<tr>
<td>3</td>
<td>signing</td><td>&lt;ExpEType type="signing" ns="urn:com:books-r-us" />
</td>
</tr>
<tr>
<td>4</td>
<td>author</td><td>&lt;ExpEType type="author" ns="urn:com:books-r-us" /> </td>
</tr>
<tr>
<td>4</td>
<td>title</td>
<td>&lt;ExpAName name='title' eltype="author" elns="urn:com:books-r-us" />
</td>
</tr>
<tr>
<td>4</td>
<td>name</td>
<td>&lt;ExpAName name='name' eltype="author" elns="urn:com:books-r-us" /></td>
</tr>
<tr>
<td>5</td>
<td>book</td><td>&lt;ExpEType type="book" ns="urn:com:books-r-us" /></td>
</tr>
<tr>
<td>5</td>
<td>title</td><td>&lt;ExpAName name='title' eltype="book" elns="urn:com:books-r-us" /></td>
</tr>
<tr>
<td>5</td>
<td>price</td><td>&lt;ExpAName name='price' eltype="book" elns="urn:com:books-r-us" /></td>
</tr>
</tbody>
</table>

<eg><![CDATA[<!-- 1 --> <RESERVATION xmlns:HTML="http://www.w3.org/TR/REC-html40">
<!-- 2 --> <NAME HTML:CLASS="largeSansSerif">Layman, A</NAME>
<!-- 3 --> <SEAT CLASS="Y" HTML:CLASS="largeMonotype">33B</SEAT>
<!-- 4 --> <HTML:A HREF='/cgi-bin/ResStatus'>Check Status</HTML:A>
<!-- 5 --> <DEPARTURE>1997-05-24T07:55:00+1</DEPARTURE></RESERVATION>]]></eg>

<table border="1" cellpadding="7">
<tbody>
<tr><td>1</td>
<td>RESERVATION</td><td>&lt;ExpEType type="RESERVATION" /></td>
</tr>
<tr>
<td>2</td>
<td>NAME</td><td>&lt;ExpEType type="NAME" /></td>
</tr>
<tr>
<td>2</td>
<td>HTML:CLASS</td>
<td>&lt;ExpAName name="CLASS" ns=<phrase diff="add">"</phrase>http://www.w3.org/TR/REC-html40<phrase diff="add">"</phrase> /></td>
</tr>
<tr>
<td>3</td>
<td>SEAT</td><td>&lt;ExpEType type="SEAT" /></td>
</tr>
<tr>
<td>3</td>
<td>CLASS</td><td>&lt;ExpAName name="CLASS" eltype="SEAT"<phrase diff="add"> /</phrase>></td>
</tr>
<tr>
<td>3</td>
<td>HTML:CLASS</td><td>&lt;ExpAName name="CLASS" ns="http://www.w3.org/TR/REC-html40" /></td>
</tr>
<tr>
<td>4</td>
<td>HTML:A</td><td>&lt;ExpEType type="A" ns="http://www.w3.org/TR/REC-html40" /></td>
</tr>
<tr>
<td>4</td>
<td>HREF</td><td>&lt;ExpAName name="HREF" eltype="A" elns="http://www.w3.org/TR/REC-html40" /></td>
</tr>
<tr>
<td>5</td>
<td>DEPARTURE</td><td>&lt;ExpEType type="DEPARTURE" /></td>
</tr>
</tbody></table>
</div2>
<div2 id='check-uniqattr'>
<head>Unique Expanded Attribute Names</head>
<p>The constraint expressed by <specref ref='uniqAttrs' /> above
may straightforwardly be implemented by requiring that
no element have
two attributes whose expanded names are equivalent, i.e. have the same
attribute-value pairs.</p>
</div2>
</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:
-->
