<!DOCTYPE spec [

<!-- The words 'FINAL EDIT' in comments mark places where changes
need to be made after approval of the document by the ERB, before
publication.  -->

<!ENTITY XML.version "1.0">
<!ENTITY doc.date "18 May 1998">
<!ENTITY iso6.doc.date "19980518">
<!ENTITY w3c.doc.date "18-May-1998">

<!ENTITY xmlspec "http://www.w3.org/TR/REC-xml" >
<!ENTITY xmlpio "'&lt;?XML'">
<!ENTITY pic    "'?>'">
<!ENTITY br     "<BR>">
<!ENTITY mdash  "--"> <!-- was: <!ENTITY mdash  "&#38;#151;"> -->
<!ENTITY com    "--">
<!ENTITY como   "--">
<!ENTITY comc   "--">
<!ENTITY hcro   "&amp;#X">
<!-- <!ENTITY nbsp " "> -->
<!ENTITY nbsp   "&#160;">
<!ENTITY IDEOSPACE "3000" >
<!ENTITY magicents "<code>amp</code>,
<code>lt</code>,
<code>gt</code>,
<code>apos</code>,
<code>quot</code>">
 
<!-- audience and distribution status:  for use at publication time -->
<!--  -->
<!ENTITY doc.audience "public review and discussion">
<!ENTITY doc.distribution "may be distributed freely, as long as
all text and legal notices remain intact">

]>

<!-- for Panorama *-->
<!-- ?VERBATIM "scrap"> -->
<?VERBATIM "eg" ?>

<spec>
<header>
<title>Namespaces in XML</title>
<version></version>
<w3c-designation>WD-xml-names-&iso6.doc.date;</w3c-designation>
<w3c-doctype>World Wide Web Consortium Working Draft</w3c-doctype>
<pubdate><day>18</day><month>May</month><year>1998</year></pubdate>
<notice><p>This draft is for public discussion.</p></notice>
<publoc>
<loc href="http://www.w3.org/TR/1998/WD-xml-names-&iso6.doc.date;">
http://www.w3.org/TR/1998/WD-xml-names-&iso6.doc.date;</loc></publoc>
<latestloc>
<loc href='http://www.w3.org/TR/1998/WD-xml-names'>http://www.w3.org/TR/1998/WD-xml-names</loc>
</latestloc>
<prevlocs>
<loc href='http://www.w3.org/TR/1998/WD-xml-names-19980327'>http://www.w3.org/TR/1998/WD-xml-names-19980327</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>Hewlett-Packard Company</affiliation>
<email href="mailto:dmh@corp.hp.com">dmh@corp.hp.com</email></author>
<author><name>Andrew Layman</name>
<affiliation>Microsoft</affiliation>
<email href="mailto:andrewl@microsoft.com">andrewl@microsoft.com</email></author>
</authlist>
<status>
<p>This draft specification is a work in progress representing the current
consensus of the W3C XML Working Group. 
This is a W3C Working Draft for review by W3C members and other interested
parties. 
Publication as a working draft does not imply endorsement by the W3C
membership. 
While we do not anticipate substantial changes, we still caution that further
changes are possible and therefore we recommend that only 
experimental software or software that can be easily field-upgraded be
implemented to this specification at this time. 
The XML Working Group will not allow early implementation to constrain its
ability to make changes to this specification 
prior to final release. 
This is a draft document and may be updated, replaced or obsoleted by other
documents at any time. 
It is inappropriate to cite W3C Working Drafts as other than "work in
progress".</p>
<p>It is the intent of the XML Working Group that this namespace facility
should become an integral part of some future version of the 
XML specification.</p>
</status> 
<abstract>
<p>XML namespaces provide a simple method for qualifying 
names used in Extensible Markup Language documents by associating them
with namespaces identified by URI.</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
<bibref ref='XML'/> where a document 
contains markup defined in multiple schemas,
which may have been authored independently.
One
motivation for this is that writing good schemas is hard, so it
is beneficial to re-use parts from existing, well-designed schemas.
Another is the advantage of allowing search engines or other
tools to operate over a range of documents that vary in many
respects but use common names for common element types. </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>XML namespaces are based on the use of
<termref def='dt-qname'>qualified names</termref>, 
<!-- fluff
similar to those long used in programming languages.
Qualified names-->
which contain a single colon, separating the name into a
<termref def='dt-prefix'>namespace prefix</termref> and the 
<termref def='dt-localname'>local name</termref>.
The prefix, which is mapped to a URI, selects a namespace. 
The combination of
the universally managed URI namespace and the local name
produces names that are guaranteed universally unique.
</p>

<p>URIs can contain characters not allowed in names, so cannot
be used directly as namespace prefixes.
Therefore, the 
namespace prefix serves as a proxy for a URI.
A special processing instruction described below is used
to <termref def='dt-NSDecl'>declare</termref> the association of the 
namespace prefix with a URI; 
software which supports this namespace proposal must
recognize and act on it.
</p>
</div1>
<div1 id='sec-syntax'>
<head>Namespace Syntax</head>
<div2 id='ns-decl'> 
<head>Declaring Namespaces</head>
<p><termdef id='dt-NSDecl' term='Namespace Declaration'>A namespace is 
<term>declared</term> using a reserved
<xtermref href="&xmlspec;#dt-pi">processing
instruction</xtermref> as follows:
<scrap lang='ebnf'>
<head>Namespace Declaration PI</head>

<prod id='NT-NDPI'><lhs>NamespacePI</lhs>
<rhs>'&lt;?xml:namespace' 
(<xnt href="&xmlspec;#NT-S">S</xnt>
(<nt def='NT-PrefixDef'>PrefixDef</nt> 
| <nt def='NT-NSDef'>NSDef</nt>
| <nt def='NT-SrcDef'>SrcDef</nt>))+ '?>'
</rhs><nsc def='nsc-AndConnector'/>
</prod>
<prod id='NT-NSDef'><lhs>NSDef</lhs>
<rhs>'ns' <xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
<xnt href="&xmlspec;#NT-SystemLiteral">SystemLiteral</xnt></rhs>
<nsc def='nsc-NoFrags' /></prod>
<prod id='NT-SrcDef'><lhs>SrcDef</lhs>
<rhs>'src' <xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
<xnt href="&xmlspec;#NT-SystemLiteral">SystemLiteral</xnt></rhs>
</prod>
<prod id='NT-PrefixDef'><lhs>PrefixDef</lhs>
<rhs>'prefix' <xnt href='&xmlspec;#NT-Eq'>Eq</xnt>
("'" <nt def="NT-NCName">NCName</nt> "'"
| '"' <nt def="NT-NCName">NCName</nt> '"')</rhs>
</prod>
<prod id='NT-NCName'><lhs>NCName</lhs>
<rhs>(<nt def='NT-Letter'>Letter</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'><lhs>NCNameChar</lhs>
<rhs><xnt href="&xmlspec;#NT-Letter">Letter</xnt>
| <xnt href='&xmlspec;#NT-Digit'>Digit</xnt> 
| '.' | '-' | '_'
| <xnt href='&xmlspec;#NT-CombiningChar'>CombiningChar</xnt>
| <xnt href='&xmlspec;#NT-Extender'>Extender</xnt></rhs>
</prod>
</scrap>
</termdef>
<termdef id='dt-schema' term='Namespace Name'>
The <xnt href="&xmlspec;#NT-SystemLiteral">SystemLiteral</xnt>
in the <nt def='NT-NSDef'>NSDef</nt> production
is a URI which functions as a <term>namespace name</term> to identify
the namespace.</termdef>
The 
<xnt href="&xmlspec;#NT-SystemLiteral">SystemLiteral</xnt> 
in the <nt def='NT-SrcDef'>SrcDef</nt> production
is an optional URI which may be used to retrieve the schema, if one
is provided.
Some namespaces need no
schemas; this specification does not depend on their existence, or on the use
of any particular machine- or human-readable syntax in the schema.
</p>

<p><termdef id='dt-prefix' term='Namespace Prefix'>The 
<nt def="NT-NCName">NCName</nt> in the
<nt def='NT-PrefixDef'>PrefixDef</nt> 
production gives the <term>namespace prefix</term>
used to associate names in an XML document
with this namespace.</termdef></p>
<nscnote id='nsc-AndConnector'>
<head>Required Parts</head>
<p>A namespace declaration must contain exactly one 
<nt def='NT-NSDef'>NSDef</nt>, exactly one
<nt def='NT-PrefixDef'>PrefixDef</nt> and zero or one 
<nt def='NT-SrcDef'>SrcDef</nt>.</p>
</nscnote>
<nscnote id='nsc-NoFrags'>
<head>No Fragments</head>
<p>The
<xnt href="&xmlspec;#NT-SystemLiteral">SystemLiteral</xnt> in
the <nt def='NT-NSDef'>NSDef</nt> 
production must contain a URI, 
<emph>not including</emph> an attached <code>#</code>-separated fragment
identifier.</p>
</nscnote>
<p>The <termref def='dt-schema'>namespace name</termref>, 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>Examples of namespace declarations:
<eg><![CDATA[<?xml:namespace ns='http://www.microsoft.com/' prefix='ms' ?>
<?xml:namespace ns='urn:ISBN:0-395-36341-6/' prefix='bk' ?>
<?xml:namespace ns='urn:uuid:C4ED1820-6207-11d1-A29F-00AA00C14882/'
                src='http://www.w3.org' prefix='w3c' ?>]]></eg>
</p>
</div2>
<div2 id='ns-decl-loc'>
<head>Placing Declarations in Documents</head>
<p><termref def='dt-NSDecl'>Namespace declarations</termref>
must be located in the 
<loc href='&xmlspec;#sec-prolog-dtd'>prolog</loc>
of an XML document, after the 
<xtermref href='&xmlspec;#dt-xmldecl'>XML
Declaration</xtermref> (if any) and before the
<xtermref href='&xmlspec;#dt-dtd'>DTD</xtermref>
(if any).
This effectively makes the scope of 
<termref def='dt-prefix'>namespace prefixes</termref> global to 
the whole document, including the DTD.
It also means that should a processor wish to insert its own qualified
names, it need only read the namespace declarations from the prolog 
to be sure of generating a new, unique, namespace prefix.</p>
<p>In XML documents conforming to this specification, the 
<xnt href='&xmlspec;#NT-prolog'>prolog</xnt>
must match the following production:
<scrap lang='ebnf'>
<head>Prolog with Namespace Declarations</head>
<prod id='NT-prolog'><lhs>prolog</lhs>
<rhs><xnt href='&xmlspec;#NT-XMLDecl'>XMLDecl</xnt>? 
<!--<xnt href="&xmlspec;#NT-S">S</xnt>?-->
(<nt def='NT-NDPI'>NamespacePI</nt> |
<xnt href='&xmlspec;#NT-Misc'>Misc</xnt>)* 
(<xnt href='&xmlspec;#NT-doctypedecl'>doctypedecl</xnt> 
<xnt href='&xmlspec;#NT-Misc'>Misc</xnt>*)?</rhs>
<nsc def='nsc-cleanDecl'/>
</prod>
</scrap>
Note that the namespace declarations are ordinary processing
instructions which the XML processor will pass to the application
as it does any other.</p>
<nscnote id='nsc-cleanDecl'>
<head>Unique Prefix</head>
<p>A <termref def='dt-prefix'>namespace prefix</termref> may not be
declared more than once; i.e. there may not be two
<nt def='NT-PrefixDef'>PrefixDefs</nt> which contain the same
<nt def='NT-NCName'>NCName</nt> string.</p>
</nscnote>

</div2>
<div2 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="&xmlspec;#NT-Name">Name</xnt>)
may be given as <term>qualified names</term>, defined as follows:
<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>
<nsc def='nsc-NSDeclared'/></prod>
<prod id='NT-LocalPart'><lhs>LocalPart</lhs>
<rhs><nt def="NT-NCName">NCName</nt></rhs>
</prod>

</scrap></termdef>
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 URI
in a
<termref def='dt-NSDecl'>namespace declaration</termref>.
<termdef id='dt-localname' term='Local Name'>
The <nt def='NT-LocalPart'>LocalPart</nt> provides the
<term>local name</term> part 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 and local name 
pair whenever a name is required whose scope extends beyond the 
containing document.</p>
<nscnote id='nsc-NSDeclared'>
<head>Prefix Declared</head>
<p>The namespace prefix, unless it is "<code>xml</code>", must have been
declared in a <termref def='dt-NSDecl'>namespace declaration</termref>.
The namespace prefix <code>xml</code> is reserved, and considered to
have been implicitly declared.
No other prefix beginning with the three-letter sequence <code>x</code>,
<code>m</code>, <code>l</code>, in any case combination, is allowed.</p>
</nscnote>
</div2>
<!--
<div2 id='ns-unames'>
<head>Universal Names</head>
<p><termdef id='UniName' term='Universal Name'>For each <termref
def='dt-qname'>qualified name</termref>, there is a corresponding
<term>universal name</term>, which is an ordered pair containing
first, the <termref def='dt-schema'>namespace name</termref> 
associated with its <termref def='dt-prefix'>prefix</termref>,
and second, its <termref def='dt-localname'>local
name</termref>.</termdef></p>
<p>A universal name is independent of the prefix in use in any particular XML
document; thus, universal names provide a basis for comparing named
objects located in different XML documents.</p>
</div2>
<div2 id='ns-equiv'>
<head>Equivalence of Qualified Names</head>
<p>In order to compare qualified names correctly, it is important to treat the
<termref def='dt-prefix'>namespace prefix</termref> merely as a placeholder
for the <termref def='dt-schema'>namespace name</termref> (URI) with which it
is associated.
<termdef id='NSEquiv' term='Equivalent'>Concretely, this means that
we can define <term>equivalence</term> in element types, attribute names, and
PI targets as follows:
<olist><item><p>If two element types
which occur in the same document have the same prefix and local
name, they are equivalent.</p></item>
<item><p>If two element types which occur in the same document have different
prefixes but the same local name, and their prefixes are associated 
with the same namespace name, they are equivalent.</p></item>
<item><p>If two element types which occur in two different documents have the
same local name, both have prefixes, and those
prefixes are associated with the same namespace name,
they are equivalent.</p></item>
</olist>
The same rules apply to any two 
<loc href='&xmlspec;#sec-pi'>PI targets</loc>, and to any two names of
attributes which are attached to equivalent element types.
</termdef></p>
<p>The following example shows the contents of two different XML
documents:
<eg><![CDATA[<?xml version='1.0' ?>
<?xml:namespace ns='http://www.w3.org/Schemas/A' prefix='w3c' ?>
<?xml:namespace ns='http://www.w3.org/Schemas/A' prefix='Consortium' ?>
<?xml:namespace ns='http://www.iso.ch/Schemas/B' prefix='ISO' ?>
<list>
 <!- - #1 - -> <w3c:Item val='1' />                 	    
 <!- - #2 - -> <Consortium:Item val='2' ISO:Class='19' /> 
 <!- - #3 - -> <ISO:Item>Three</ISO:Item>           	    
 </list>
<!- - End of Document 1 - ->

<?xml version='1.0' ?>
<?xml:namespace ns='http://www.w3.org/Schemas/A' prefix='w3.org' ?>
<?xml:namespace ns='http://www.iso.ch/Schemas/B' prefix='iso' ?>
<?xml:namespace ns='http://www.nist.gov/Schemas/C' prefix='NIST' ?>
<list>
 <!- - #4 - -> <w3.org:Item iso:Class='77' val='1' />        
 <!- - #5 - -> <NIST:Item w3.org:Class='a' iso:Class='42' /> 
 </list>]]></eg>
In these examples:
<olist><item><p>Element #1, Element #2, and Element #4 are all of equivalent
type.</p>
</item>
<item><p>The type of Element #3 is not equivalent to that of any other element.</p></item>
<item><p>The <code>val</code> attribute of Element #1 and the <code>val</code>
attribute of Element #4 have equivalent names.</p></item>
<item><p>The <code>ISO:Class</code> attribute of Element #2 and the
<code>iso:Class</code> attribute of Element #4 have equivalent
names.</p></item>
<item><p>The <code>iso:Class</code> attribute of Element #4 and the
<code>iso:Class</code> attribute of Element #5 do <emph>not</emph> have
equivalent names, because the types of the elements to which they are attached
are not equivalent.</p>
</item>
</olist>
</p>
<p>Note that two names which are equivalent may not 
<xtermref href='&xmlspec;#elementvalid'>match</xtermref> in the sense defined in
the XML spec.
This means that in order to perform 
<xtermref href='&xmlspec;#dt-valid'>validation</xtermref>, it may be necessary
to rewrite or insert prefixes in declarations and tags in
order to 
make element types and attribute 
names which are equivalent match.</p>
</div2>
-->
<div2 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.
In the productions below, the nonterminals 
(<xnt href="&xmlspec;#NT-STag">STag</xnt>,
<xnt href="&xmlspec;#NT-ETag">ETag</xnt>,
<xnt href="&xmlspec;#NT-EmptyElement">EmptyElement</xnt>,
and 
<xnt href="&xmlspec;#NT-Attribute">Attribute</xnt>)
are taken from the XML specification <bibref ref='XML'/>; 
the productions in all cases match a subset of the strings matched by those of
the same name in the XML spec.
<scrap lang='ebnf'>
<head>Element Types and Attribute 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>
</prod>
<prod id='NT-ETag'><lhs>ETag</lhs>
<rhs>'&lt;/' <nt def='NT-QName'>QName</nt> 
<xnt href='&xmlspec;#NT-S'>S</xnt>? '>'</rhs></prod>
<prod id='NT-EmptyElement'><lhs>EmptyElement</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>
</prod>
</scrap>
</p>
<p>
Attribute names are given as
<termref def='dt-qname'>qualified names</termref>,
as follows:
<scrap lang='ebnf'>
<head>Attribute</head>
<prod id='NT-Attribute'><lhs>Attribute</lhs>
<rhs><nt def='NT-QName'>QName</nt> <xnt href='&xmlspec;#NT-Eq'>Eq</xnt> 
<xnt href='&xmlspec;#NT-AttValue'>AttValue</xnt></rhs>
</prod>
<!-- 

Retitle 2.5 attributes
"Suppose that in some doc...  - reword to say instad of impossible... 
this spec doesn't do it."  And fix suggestion that we're inventing
syntax in last example.  CamelCase. & point out that unqual attrs have
the same problem.
-->
</scrap>
An attribute whose name is not qualified, but which is attached to an element
whose type is qualified, is in the namespace of the element type prefix.
This specification does not provide a syntactic mechanism for determining
whether the significance of, or definition for, the attribute is dependent on
the element type to which it is attached; see 
<specref ref='Ambiguity'/>.</p>
<!-- casualties
In the following example, the <code>href</code> is considered to come from the
namespace associated with the prefix <code>html</code>.
<eg><![CDATA[<html:a href='http://www.w3.org'>The W3C</html:a>]]></eg>
Thus, the following would be equivalent:
<eg><![CDATA[<html:a html:href='http://www.w3.org'>The W3C</html:a>]]></eg>
-->
<p>Element names and attribute types are also given as qualified names when
they appear in declarations in the 
<xtermref href='&xmlspec;#dt-dtd'>DTD</xtermref>:
<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>)* 
']' 
<nt def='NT-S'>S</nt>?)? '>'</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> 
<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>
<p><xnt href='&xmlspec;#dt-pi'>Processing instruction</xnt> targets
are given as 
<termref def='dt-qname'>qualified names</termref>,
as follows:
<scrap lang='ebnf'>
<head>PI Target</head>
<prod id='NT-PITarget'><lhs>PITarget</lhs>
<rhs><nt def='NT-QName'>QName</nt>
</rhs><nsc def='piPrefix'/></prod></scrap>
</p>
<nscnote id='piPrefix'>
<head>Declare Before Use</head>
<p>When a PI target, aside from that in a namespace declaration PI,
is qualified with a prefix, that prefix must
be declared at a location in the document which precedes its use.</p>
</nscnote>
</div2>
<div2 id='Ambiguity'><head>Ambiguity In Attributes</head>
<p>When a schema is provided for a namespace, there is no guarantee that
the combination of namespace name and attribute name will
provide sufficient information to locate the appropriate description
in the schema (if any exists) for the attribute.
The XML document type definition is an example of a schema language in which 
this is possible.
In a DTD, many attributes can be declared which share a
name; they are distinguished by being attached to different element
types.</p>
<p>This ambiguity is not always a problem.
Consider one of the HTML 4.0 
DTDs, which define two attributes, <code>CLASS</code> and <code>STYLE</code>,
for use with stylesheets.
The DTD and accompanying description define
this attribute in such a way that it may apply to 
virtually every element, and that its semantics are identical wherever 
applied.
Thus, given a prefix <code>html</code> which selects a 
namespace whose schema is that of 
HTML 4.0, the following would present no problems:
<eg><![CDATA[<Warning html:class='Important'>Sudden death may ensue.</Warning>]]></eg>
</p>
<p>On the other hand, consider a document that uses data types
defined by ISO Standard 31, which deals with units of measure.
In ISO 31, the unit "degrees" can apply
to measures of several very different quantities.
Thus, assuming the prefix <code>ISO</code> denotes a namespace associated with
ISO 31, whatever the schema language in use, the following would almost
certainly be ambiguous:
<eg><![CDATA[<Item ISO:degrees='31'/>]]></eg>
</p>
<p>To make this more concrete, consider a schema which is an XML DTD 
containing the following declarations:
<eg><![CDATA[<!ATTLIST Heat  Temp CDATA #IMPLIED>
<!ATTLIST Color Temp (3200|3400|5500) #IMPLIED>]]></eg>
Suppose that in some document this DTD is associated with a namespace
identified by the 
prefix <code>T</code>.
Then, in the following example, the syntax described in this specification
does not provide sufficient information to distinguish
whether <code>T:Temp</code> is the <code>Temp</code> attribute associated with
the  <code>Heat</code> element, or that associated with the <code>Color</code>
element:
<eg><![CDATA[<Item T:Temp='3400'/>]]></eg>
</p>
<p>In practical terms, it is expected that applications which process
attributes will have built-in knowledge as to their meaning and the effect (if
any) of their element context.
Thus this should not be problem operationally.
However, it can in general be addressed by using multiple
namespaces. 
In the immediately preceding example, it would be necessary to
declare namespaces with prefixes, for example, <code>TempHeat</code> and
<code>TempColor</code>, whose associated 
<termref def='dt-schema'>namespace names</termref> would select the parts of
the schema that described, respectively, the attributes of the
<code>Heat</code> and <code>Color</code> attributes.
Then the example could be disambiguated as follows:
<eg><![CDATA[<Item TempHeat:Temp='3400'/>]]></eg>
</p>
</div2>
<div2 id='Conformance'>
<head>Conformance</head>
<p>Names in XML documents which conform to this specification are
element types, attribute names and PI targets which match the production for 
<nt def='NT-QName'>QName</nt>.</p>
<p>An XML document conforms to this specification if all other 
tokens in the document which are required, for XML conformance, to match the
XML production for <xnt href="&xmlspec;#NT-Name">Name</xnt>, match
this specification's production for <nt def='NT-NCName'>NCName</nt>.
<!--
The single exception to this rule is for
<loc href='&xmlspec;#sec-pi'>PI targets</loc>, which may be
qualified names, but only with the <termref def='dt-prefix'>prefix</termref>
<code>xml</code>.--></p>
<p>The effect of conformance is that in such a document:
<ulist><item><p>All element types, attribute names and
PI targets contain either zero
or one colon.</p></item>
<item><p>No entity names or notation names contain any colons.</p>
</item>
</ulist></p>
<p>Strictly speaking, attribute values declared to be of types
<kw>ID</kw>, <kw>IDREF(S)</kw>, <kw>ENTITY(IES)</kw>,
and <kw>NOTATION</kw> are also <xnt href="&xmlspec;#NT-Name">Names</xnt>,
and thus should be colon-free.
However, the declared type of attribute values is in principle only available
in documents which have been
<xtermref href='&xmlspec;#dt-validating'>validated</xtermref>.
Thus, in <xtermref href='&xmlspec;#dt-wellformed'>well-formed</xtermref> XML
documents, there can be no assurance that the contents of attribute values
have been checked for conformance to this specification.</p>
</div2>
</div1>

<div1 id='sec-example'>
<head>Examples</head>
<div2 id='syntax-eg'>
<head>The On-line Bookstore</head>
<p>Imagine an XML document representing an invoice for books. If
public schemas exist for elements and attributes describing
books, electronic transactions and digital signatures, the
invoice author should be able to use these, rather than inventing
new element and attribute types. Any reader of the invoice
document should be able to infer a consistent meaning to its
contents, the same meaning as if the elements and attributes had
appeared in a different kind of document (such as an invoice for
automotive parts, or an inventory of books or a digital signature
on a legal contract). A search tool should be able
to locate the elements,
regardless of the document in which they reside. Further, since
several schemas may choose the same name (e.g. &quot;size&quot;)
for elements or attributes with different meanings, these must be
distinguished if used within the same document.</p>

<eg><![CDATA[<?xml:namespace ns="http://books.org/schema/" prefix="B"?>
<?xml:namespace ns="http://ecommerce.org/schema/" prefix="E"?>
<?xml:namespace ns="http://digitalSignatures.org/schema/" prefix="dsig"?>
<?xml:namespace ns="urn:uuid:C2F41010-65B3-11d1-A29F-00AA00C14882/" 
     prefix="dt"?>

<E:Order>
 <dsig:dsig>
   <E:Manifest>80183589575795589189518915</E:Manifest>
   <E:Sig href="http://XYX/Joe@company.com"/>
 </dsig:dsig>
 <E:SoldTo>
   <E:LastName>Layman</E:LastName>
   <E:FirstName>Andrew</E:FirstName>
 </E:SoldTo>

 <E:SoldOn dt:baseType="date.iso8601">1997-03-17</E:SoldOn>
 <E:Item Price="5.95">
   <B:BOOK TITLE="Number, the Language of Science" 
           AUTHOR="Dantzig, Tobias"/>
 </E:Item>
 <E:Item Price="12.95">
   <B:BOOK TITLE="Introduction to Objectivist Epistemology"
           AUTHOR="Rand, Ayn"/>
 </E:Item>
</E:Order>]]></eg>
</div2>
</div1>
</body>
<back>
 
<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.</p>
</div1>
<div1 id='refs'>
<head>References</head>
<blist>
<bibl id='URNs' key='RFC2141'>
IETF (Internet Engineering Task Force)
<emph>RFC 2141: URN Syntax</emph>, ed. R. Moats. May 1997.
</bibl>
<bibl id='XML' key='XML'>
<em>Extensible Markup Language
(XML) 1.0</em>, eds. Tim Bray, Jean
Paoli, and C. M.
Sperberg-McQueen.
10 February 1998. Available at
http://www.w3.org/TR/REC-xml.
</bibl>
</blist>
</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:
-->
