home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
XML Bible (2nd Edition)
/
XML_Bible_Second_Edition_Hungry_Minds_2001.iso
/
pc
/
specs
/
xml-names.xml
< prev
next >
Wrap
Extensible Markup Language
|
2001-04-26
|
34KB
|
874 lines
<?xml version='1.0' encoding='ISO-8859-1' standalone='no'?>
<!DOCTYPE spec SYSTEM "spec.dtd" [
<!ENTITY iso6.doc.date "19990114">
<!ENTITY xmlspec "http://www.w3.org/TR/REC-xml" >
<!ENTITY cellback '#c0d9c0'>
]>
<spec>
<header>
<title>Namespaces in XML</title>
<w3c-designation>REC-xml-names-&iso6.doc.date;</w3c-designation>
<w3c-doctype>World Wide Web Consortium</w3c-doctype>
<pubdate><day>14</day><month>January</month><year>1999</year></pubdate>
<notice><p>This draft is for public discussion.</p></notice>
<publoc>
<loc href="http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;">
http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;</loc>
<loc href="http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/xml-names.xml">
http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/xml-names.xml</loc>
<loc href="http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/Overview.html">
http://www.w3.org/TR/1999/REC-xml-names-&iso6.doc.date;/Overview.html</loc>
</publoc>
<latestloc>
<loc href='http://www.w3.org/TR/REC-xml-names'>http://www.w3.org/TR/REC-xml-names</loc>
</latestloc>
<prevlocs>
<loc href="http://www.w3.org/TR/1998/PR-xml-names-19981117">
http://www.w3.org/TR/1998/PR-xml-names-19981117</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 document has been reviewed by W3C Members and
other interested parties and has been endorsed by the
Director as a W3C Recommendation. It is a stable
document and may be used as reference material or cited
as a normative reference from another document. W3C's
role in making the Recommendation is to draw attention
to the specification and to promote its widespread
deployment. This enhances the functionality and
interoperability of the Web.</p>
<p>The list of known errors in this specification is
available at
<loc href='http://www.w3.org/XML/xml-names-19990114-errata'>http://www.w3.org/XML/xml-names-19990114-errata</loc>.</p>
<p>Please report errors in this document to
<loc href='mailto:xml-names-editor@w3.org'>xml-names-editor@w3.org</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 URI 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 a URI reference
<bibref ref='URIRef'/>,
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'>URI references which
identify namespaces are considered <term>identical</term> when they are
exactly the same character-for-character.</termdef>
Note that URI references which are not identical in this sense may in fact be
functionally equivalent.
Examples include URI references which differ only in case, or which are in
external entities which have different effective base URIs.
</p>
<p>Names from XML namespaces may appear as
<termref def='dt-qname'>qualified names</termref>,
which 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 a URI reference, selects a namespace.
The combination of
the universally managed URI namespace and the document's own namespace
produces identifiers that are universally unique.
Mechanisms are provided for prefix scoping and defaulting.
</p>
<p>URI 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 a URI reference.
An attribute-based syntax described below is used
to <termref def='dt-NSDecl'>declare</termref> the association of the
namespace prefix with a URI 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'><lhs>NCName</lhs>
<rhs>(<xnt href='&xmlspec;#NT-Letter'>Letter</xnt> | '_')
(<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>
<p>
<termdef id='dt-NSName' term="Namespace name">The attribute's
<xtermref href="&xmlspec;#dt-attrval">value</xtermref>,
a URI 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>
In such declarations, the namespace name may not be empty.</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>
In such a default declaration, the attribute value may be empty.
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>:
<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>
</p>
<nscnote id='xmlReserved'>
<head>Leading "XML"</head>
<p>Prefixes beginning with the three-letter sequence <code>x</code>,
<code>m</code>, <code>l</code>, in any case combination, are reserved
for use by XML and XML-related specifications.</p>
</nscnote>
</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="&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></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
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:
<scrap lang='ebnf'>
<head>Element Types</head>
<prod id='NT-STag'><lhs>STag</lhs>
<rhs>'<' <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>'</' <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>'<' <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>
<p>An example of a qualified name serving as an element type:
<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>
<p>
Attributes are either <termref def='dt-NSDecl'>namespace
declarations</termref>
or their names are given as
<termref def='dt-qname'>qualified names</termref>:
<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>
<p>An example of a qualified name serving as an attribute name:
<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>
</p>
<nscnote 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 an ancestor element (i.e. an element in whose
<xtermref href='&xmlspec;#dt-content'>content</xtermref> the
prefixed markup occurs).
The prefix <code>xml</code> is by definition bound to the
namespace name <code>http://www.w3.org/XML/1998/namespace</code>.
The prefix <code>xmlns</code> is used only for namespace bindings
and is not itself bound to any namespace name.
</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-dtd'>DTD</xtermref>:
<scrap lang='ebnf'>
<head>Qualified Names in Declarations</head>
<prod id='NT-doctypedecl'><lhs>doctypedecl</lhs>
<rhs>'<!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>'<!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>'<!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>? '>'</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>
</div1>
<div1 id='scoping-defaulting'>
<head>Applying Namespaces to Elements and Attributes</head>
<div2 id='scoping'>
<head>Namespace Scoping</head>
<p>The namespace 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 namespace declaration
with the same <nt def='NT-NSAttName'>NSAttName</nt> part:
<eg><![CDATA[<?xml version="1.0"?>
<!-- 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>
<p>Multiple namespace prefixes can be declared as attributes of a single element,
as shown in this example:
<eg><![CDATA[<?xml version="1.0"?>
<!-- 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>
</div2>
<div2 id='defaulting'>
<head>Namespace Defaulting</head>
<p>A <termref def='dt-defaultNS'>default namespace</termref> is considered
to apply to the element where it is declared (if that element has no
<termref def='dt-prefix'>namespace prefix</termref>), and to all elements
with no prefix within the content of that
element.
If the URI 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.
<eg><![CDATA[<?xml version="1.0"?>
<!-- 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><![CDATA[<?xml version="1.0"?>
<!-- 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>
<p>A larger example of namespace scoping:
<eg><![CDATA[<?xml version="1.0"?>
<!-- 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>
<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.
<eg><![CDATA[<?xml version='1.0'?>
<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>
</p>
</div2>
<div2 id='uniqAttrs'>
<head>Uniqueness of Attributes</head>
<p>In XML documents conforming
to this specification, no tag
may contain two attributes which:
<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>
<p>For example, each of the <code>bad</code> start-tags is illegal in the
following:
<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>
However, each of the following is legal, the second because the default
namespace does not apply to attribute names:
<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>
</p>
</div2>
</div1>
<div1 id='Conformance'>
<head>Conformance of Documents</head>
<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".</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>.
</p>
<p>The effect of conformance is that in such a document:
<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>
<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 only available
to processors which read markup declarations, for example
<xtermref href='&xmlspec;#dt-validating'>validating processors</xtermref>.
Thus, unless the use of a validating processor has been specified,
there can be no assurance that the contents of attribute values
have been checked for conformance to this specification.</p>
</div1>
</body>
<back>
<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:
<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>
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:
<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>
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>XML 1.0 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 XML 1.0.
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:
<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>
The names would expand as follows:
<table bgcolor="&cellback;" 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><ExpEType type="section" ns="urn:com:books-r-us" /> </td></tr>
<tr><td>2</td>
<td>title</td><td><ExpEType type="title" ns="urn:com:books-r-us" /> </td>
</tr>
<tr>
<td>3</td>
<td>signing</td><td><ExpEType type="signing" ns="urn:com:books-r-us" />
</td>
</tr>
<tr>
<td>4</td>
<td>author</td><td><ExpEType type="author" ns="urn:com:books-r-us" /> </td>
</tr>
<tr>
<td>4</td>
<td>title</td>
<td><ExpAName name='title' eltype="author" elns="urn:com:books-r-us" />
</td>
</tr>
<tr>
<td>4</td>
<td>name</td>
<td><ExpAName name='name' eltype="author" elns="urn:com:books-r-us" /></td>
</tr>
<tr>
<td>5</td>
<td>book</td><td><ExpEType type="book" ns="urn:com:books-r-us" /></td>
</tr>
<tr>
<td>5</td>
<td>title</td><td><ExpAName name='title' eltype="book" elns="urn:com:books-r-us" /></td>
</tr>
<tr>
<td>5</td>
<td>price</td><td><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 bgcolor="&cellback;" border="1" cellpadding="7">
<tbody>
<tr><td>1</td>
<td>RESERVATION</td><td><ExpEType type="RESERVATION" /></td>
</tr>
<tr>
<td>2</td>
<td>NAME</td><td><ExpEType type="NAME" /></td>
</tr>
<tr>
<td>2</td>
<td>HTML:CLASS</td>
<td><ExpAName name="CLASS" ns=http://www.w3.org/TR/REC-html40 /></td>
</tr>
<tr>
<td>3</td>
<td>SEAT</td><td><ExpEType type="SEAT" /></td>
</tr>
<tr>
<td>3</td>
<td>CLASS</td><td><ExpAName name="CLASS" eltype="SEAT"></td>
</tr>
<tr>
<td>3</td>
<td>HTML:CLASS</td><td><ExpAName name="CLASS" ns="http://www.w3.org/TR/REC-html40" /></td>
</tr>
<tr>
<td>4</td>
<td>HTML:A</td><td><ExpEType type="A" ns="http://www.w3.org/TR/REC-html40" /></td>
</tr>
<tr>
<td>4</td>
<td>HREF</td><td><ExpAName name="HREF" eltype="A" elns="http://www.w3.org/TR/REC-html40" /></td>
</tr>
<tr>
<td>5</td>
<td>DEPARTURE</td><td><ExpEType type="DEPARTURE" /></td>
</tr>
</tbody></table>
</p>
</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>
<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='URIRef' key='RFC2396'>
IETF (Internet Engineering Task Force)
<emph>RFC 2396: Uniform Resource Identifiers (URI): Generic Syntax</emph>, eds.
T. Berners-Lee, R. Fielding, L. Masinter.
August 1998.
</bibl>
<bibl id='XML' key='XML'>
<emph>Extensible Markup Language
(XML) 1.0</emph>, eds. Tim Bray, Jean
Paoli, and C. M.
Sperberg-McQueen.
10 February 1998. Available at
<loc href="http://www.w3.org/TR/REC-xml">http://www.w3.org/TR/REC-xml</loc>.
</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:
-->