Lists Home |
Date Index |
- From: "Paul W. Abrahams" <firstname.lastname@example.org>
- To: email@example.com
- Date: Wed, 16 Aug 2000 14:54:52 -0400
Here's a suggestion as to how namespaces might be made to work with DTDs while
doing minimal violence either to the XML spec or the namespace spec.
The usual method of incorporating a DTD into a document's "doctypedecl" is first
to declare a parameter entity and then to summon it with a parameter-entity
reference. The syntax of the PEDecl that declares the entity is:
PEDecl ::= `<!ENTITY ' S "%" Name S EntityDef S? '>'
Now suppose we adopt the convention that a Name ending in a colon designates
both a DTD and a namespace prefix. The EntityDef says where the DTD is to be
found; we reinterpret the retrieval process to prefix each element name within
the DTD with the Name. Since the XML spec says that the EntityDef is used to
retrieve the entity but does not say precisely what that retrieval process is,
we're still consistent with XML 1.0.
For example, suppose that the following DTD is to be found at zoo.dtd:
<!ELEMENT zoo (animal*)>
<!ATTLIST zoo city CDATA #REQUIRED >
<!ELEMENT animal (#PCDATA)>
Suppose further that we have the document:
<!ENTITY % zo: "SYSTEM "zoo.dtd">
<zo:zoo "xmlns:zo="zoo.dtd" city="Vladivostok">
The DTD given above is reinterpreted as:
<!ELEMENT zo:zoo (zo:animal*)>
<!ATTLIST zo:zoo city CDATA #REQUIRED >
<!ELEMENT zo:animal (#PCDATA)>
Note that attribute names are unaffected by this reinterpretation. The use of
"zoo.dtd" both as namespace URI and DTD location is natural but not required.
This approach has some important advantages:
1. It works for arbitrary namespace prefixes. In contrast, the use of a
parameter-entity reference as a prefix on all the element names in a DTD
effectively globalizes the reference's name; no two published DTDs can use the
same parameter reference.
2. It utilizes a syntactic niche (parameter names ending with a colon) that is
almost certainly not yet occupied and does not alter the set of well-formed
3. It does not require the use of a PI, yet has the effect of a PI.
4. It is simple.