]>
This draft is for public discussion. 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. The list of known errors in this specification is
available at
Please report errors in this document to
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. Created in electronic form. 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.
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.
These considerations require that document
constructs
should have universal names,
whose scope extends beyond their
containing document.
This specification describes a mechanism,
Names from XML namespaces may appear as
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 Note that many of the
nonterminals in the productions in
this specification are defined not here but in
the XML specification In this document's productions,
the Note that all Internet domain names used in
examples, with the exception of
An example namespace declaration, which associates the
namespace prefix Prefixes beginning with the three-letter sequence Note that the prefix functions In XML documents conforming to this specification,
element types are given as
An example of a qualified name serving as an element type:
Attributes are either An example of a qualified name serving as an attribute name:
The namespace prefix, unless it is This constraint may lead to operational difficulties in the case where
the namespace declaration attribute is provided, not directly in the XML
Element names and attribute types are also given as qualified names when
they appear in declarations in the
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 Multiple namespace prefixes can be declared as attributes of a single element,
as shown in this example:
A Moved to
here. A larger example of namespace scoping:
This is a funny book!
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.
In XML documents conforming
to this specification, no tag
may contain two attributes which:
have identical names, or have qualified names with the same
For example, each of the In XML documents which conform to this specification,
element types and attribute names must match the production for
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 The effect of conformance is that in such a document:
All element types and attribute names contain either zero
or one colon. No entity names, PI targets, or notation names contain any colons. Strictly speaking, attribute values declared to be of types
In the computing disciplines, the term "namespace" conventionally refers to
a 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:
XML 1.0 does not provide a built-in way to declare "global" attributes;
items such as the HTML 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:
All element types in an XML namespace appear in this partition.
Each has a unique 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. 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. 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. 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. 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:
NSC
is a "Namespace Constraint",
one of the rules that documents conforming to this specification must follow.
w3.org
, are selected
at random and should not be taken as having any import.http://ecommerce.org/schema
:
x
,
m
, l
, in any case combination, are reserved
for use by XML and XML-related specifications.xml
or xmlns
, must have been
declared in a xml
is by definition bound to the
namespace name http://www.w3.org/XML/1998/namespace
.
The prefix xmlns
is used only for namespace bindings
and is not itself bound to any namespace name.
Name Origin Description
bad
start-tags is illegal in the
following:
title
within markup, and the name alone clearly provides insufficient information
to allow correct processing by a software module.CLASS
attribute, which describes the fare basis
and takes values such as "J", "Y", and "C", is distinct at all semantic levels
from the HTML:CLASS
attribute, which
is used to
simulate syntactic richness in HTML, as a means of overcoming the
limited element repertoire by subclassing.CLASS
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.ExpEType
.
It has a required type
attribute which
gives the type's ns
attribute which, if the element is qualified, gives its
ExpAName
.
It has a required name
attribute which gives the name.
If the attribute is global, it has a required ns
attribute
which gives the eltype
which
gives the type of the attached element, and an optional attribute
elns
which gives the namespace name, if known, of the
attached element.
Line Name Expanded
1 section
<ExpEType type="section" ns="urn:com:books-r-us" /> 2
title <ExpEType type="title" ns="urn:com:books-r-us" />
3
signing <ExpEType type="signing" ns="urn:com:books-r-us" />
4
author <ExpEType type="author" ns="urn:com:books-r-us" />
4
title
<ExpAName name='title' eltype="author" elns="urn:com:books-r-us" />
4
name
<ExpAName name='name' eltype="author" elns="urn:com:books-r-us" />
5
book <ExpEType type="book" ns="urn:com:books-r-us" />
5
title <ExpAName name='title' eltype="book" elns="urn:com:books-r-us" />
5
price <ExpAName name='price' eltype="book" elns="urn:com:books-r-us" />
1
RESERVATION <ExpEType type="RESERVATION" />
2
NAME <ExpEType type="NAME" />
2
HTML:CLASS
<ExpAName name="CLASS" ns=http://www.w3.org/TR/REC-html40 />
3
SEAT <ExpEType type="SEAT" />
3
CLASS <ExpAName name="CLASS" eltype="SEAT">
3
HTML:CLASS <ExpAName name="CLASS" ns="http://www.w3.org/TR/REC-html40" />
4
HTML:A <ExpEType type="A" ns="http://www.w3.org/TR/REC-html40" />
4
HREF <ExpAName name="HREF" eltype="A" elns="http://www.w3.org/TR/REC-html40" />
5
DEPARTURE <ExpEType type="DEPARTURE" />
The constraint expressed by
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.