http://www.w3.org/TR/1998/WD-xml-names-19980731
although right now the "latest version" page
http://www.w3.org/TR/WD-xml-names
still points to the May 18 version. Check out this change in the
"status of this document" section.
May 18 version:
> 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.
July 31 version contains this addition:
> This draft embodies a large-scale revision of the namespace
> specification. While it is unfinished in some respects, the Working
> Group intends to keep the features it describes functionally unchanged
> unless problems are discovered during early implementation work. To
> discover such problems as quickly as possible, a special editorial team
> has been formed to receive feedback from implementors during a one-month
> period beginning with the publication of the working draft and ending
> shortly after the XML Working Group meeting in Montreal August 22-23.
> Please send implementation experience reports to xml-names-issues@w3.org
Wow, sounds like a pretty tight schedule, considering how profoundly
this will affect the Web.
On further read, I see that the July 31 version of namespaces looks to
be incompatible with the May 18 version, as far as the syntax for
declaring namespaces is concerned. See section 2.1 of both documents,
summarized below.
The May 18 version of namespace declarations uses a reversed processing
instruction:
> [1] NamespacePI ::= '<?xml:namespace' (S (PrefixDef | NSDef |
> SrcDef))+ '?>' [ NSC: Required Parts ]
> [2] NSDef ::= 'ns' Eq SystemLiteral [ NSC: No Fragments ]
> [3] SrcDef ::= 'src' Eq SystemLiteral
> [4] PrefixDef ::= 'prefix' Eq ("'" NCName "'" | '"' NCName '"')
> [5] NCName ::= (Letter | '_') (NCNameChar)* /* An XML Name, minus the
> ":" */
> [6] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar |
> Extender
So, for example, back then a namespace could be declared with
<?xml:namespace ns='urn:uuid:C4ED1820-6207-11d1-A29F-00AA00C14882/'
src='http://www.w3.org' prefix='w3c' ?>
The July 31 version of namespace declarations uses an attribute whose
prefix is xmlns:
> [1] NSDef ::= PrefixDef Eq SystemLiteral [ NSC: Empty URI ]
> [2] PrefixDef ::= 'xmlns' (':' NCName)?
> [3] NCName ::= (Letter | '_') (NCNameChar)*
> /* An XML Name, minus the ":" */
> [4] NCNameChar ::= Letter | Digit | '.' | '-' | '_' | CombiningChar |
> Extender
So, for example, now a namespace would be declared with
<?xml version="1.0"?>
<x xmlns:edi='http://ecommerce.org/schema'>
<!-- the edi namespace applies to the "x" element and contents -->
</x>
What else is new? The July 31 spec has a section 5 (namespace scoping
and defaulting) -- essentially, each namespace prefix is scoped to the
tag that introduces it, and there's a way to declare default namspace
prefixes:
http://www.w3.org/TR/1998/WD-xml-names-19980731#scoping-defaulting
Also, the July 31 spec has a section 6 (internal structure of XML
namespaces) -- here's where we get the philosophy of namespaces:
http://www.w3.org/TR/1998/WD-xml-names-19980731#Philosophy
I'm including these below for FoRK's scrapbook...
5. Namespace Scoping and Defaulting
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 overriden by another namespace declaration with the same
PrefixDef part:
<?xml version="1.0"?>
<!-- everything here is 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>
Multiple namespace prefixes can be declared as attributes of a single
element, as shown in this example:
<?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>
A default namespace is considered to apply to the element where it is
declared (if that element has no namespace prefix), and to all elements
with no prefix within the content of that element. Note that default
namespaces do not apply directly to attributes (see below).
<?xml version="1.0"?>
<!-- once again, everything is in the HTML namespace, 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>
<?xml version="1.0"?>
<!-- unprefixed names 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>
Attributes differ from elements in that, when unprefixed, their
namespace is not directly affected by default namespace declarations.
Rather, the namespace of an unprefixed attribute is a function of the
type of the element to which it is attached, and to the namespace (if
any) of that element. For details, see "6. The Internal Structure of XML
Namespaces".
A larger example of namespace scoping:
<?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>
<!-- drop the default into HTML for some commentary -->
<p xmlns='urn:w3-org-ns:HTML'>
This is a <i>funny</i> book!
</p>
</notes>
</book>
The default namespace, once declared, may be overriden:
<?xml version='1.0'?>
<Beers>
<!-- the default namespace is now that of HTML -->
<table xmlns='http://www.w3.org/TR/REC-html40'>
<tr><td>Name</td><td>Origin</td><td>Description</td></tr>
<tr>
<!-- drop the HTML 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>
6. The Internal Structure of XML Namespaces
6.1 The Insufficiency of the Traditional Namespace
In the computing disciplines, the term "namespace" conventionally refers
to a set 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:
<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>
In this example, there are three occurrences of the name title within
markup, and the name alone clearly provides insufficient information to
allow correct processing by a software module.
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:
<RESERVATION>
<NAME HTML:CLASS="largeSansSerif">Layman, A</NAME>
<SEAT CLASS="Y" HTML:CLASS="largeMonotype">33B</SEAT>
<DEPARTURE>1997-05-24T07:55:00+1</DEPARTURE></RESERVATION>
In this case, the 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 achieve CSS
formatting effects.
XML 1.0 does not provide a built-in way to declare "global" attributes;
items such as the HTML 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.
6.2 XML Namespace Partitions
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, which we call namespace
partitions. The partitions are:
The All Element Types Partition
All element types in an XML namespace appear in this partition.
Each has a unique local part; the combination of the namespace name and
the local part uniquely identifies the element type.
The Global Attribute Partition
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.
The Per Element Type Partitions
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 unqualified attribute partition.
6.3 Expanded Element Types and Attribute Names
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.
[Definition:] An expanded element type is expressed as an empty XML
element of type ExpEType. It has a required type attribute which gives
the type's LocalPart, and an optional ns attribute which, if the element
is qualified, gives its namespace name.
[Definition:] An expanded attribute name is expressed as an empty XML
element of type 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 namespace name; otherwise, it has a required attribute
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.
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:
<!-- 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>
The names would expand as follows: 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 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>
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" />
6.4 Unique Expanded Attribute Names
In an XML document conforming to this specification, no element may have
two attributes whose expanded names are equivalent, i.e. have the same
attribute-value pairs and child elements with the same content.
----
adam@cs.caltech.edu
I have the tendency to wear my mind on my sleeve; I have a history of
losing my shirt.
-- Barenaked Ladies, "One Week"