Namespaces: prefixes vs. no prefixes

Ron Bourret rbourret at dvs1.informatik.tu-darmstadt.de
Wed Jul 29 10:50:00 BST 1998


[Forwarded for Murray Altheim]

rbourret at dvs1.informatik.tu-darmstadt.de (Ron Bourret) writes:
> 
> This is undoubtedly a no-brainer, but it has just now occurred to me that the 
> following two DTDs are almost certainly not the same.
> 
> <!ELEMENT A (B+)>
> <!ELEMENT B (#PCDATA)>
> 
> and
> 
> <!ELEMENT FOO:A (FOO:B+)>
> <!ELEMENT FOO:B (#PCDATA)>
> 
> Originally, I had thought that instances of the first case would be recognized 
> by applications designed for the second -- that is, an application would have 
a 
> "default" namespace) -- but now I am leaning the other way.  The namespace 
spec 
> does not describe how to compare names, so I am assuming that they are first 
> resolved into fully qualified names and then compared stringwise.

This is the only way that a comparison could occur. XML 1.0 processors would
not be capable of this, so the DTD itself must be modified.
 
> One of the consequences of this is that if namespace prefixes are used in a 
DTD, 
> they must be used in both the instance file and in the application.  (Of 
course, 
> it is easy to imagine an application implementing a default namespace for 
> backward compatibility, but this is outside the spec.)
> 
> Could somebody confirm that these DTD are, in fact, different?

It really depends on how you frame your question. In the context of 
namespaces, they are theoretically the same since the element type names
are now merely qualified by a namespace prefix.

But strictly from an SGML and XML 1.0 standpoint, they are of course not
the same. The element type 'A' is now transformed to an element type 
'FOO:A'. As some are wont to note, computers are stupid, so parsing a
ns-qualified document with an unqualified DTD will (quite correctly) 
throw a validation error.

If a namespace-aware processor reads an unqualified external DTD and has
access to the proper prefix (ie., the ns declaration occurs before the 
parser begins reading the DTD), then theoretically it could modify the DTD
on the fly to grok the qualified document instance. I've been playing with
this idea for several weeks. It relies on the ability of the parser to 
have access to the ns declaration before the DTD.

But to answer your question, these two DTDs are in fact different. 

Murray
...........................................................................
Murray Altheim, SGML Grease Monkey         <mailto:altheim&#64;eng.sun.com>
Member of Technical Staff, Tools Development & Support
Sun Microsystems, 901 San Antonio Rd., UMPK17-102, Palo Alto, CA 94303-4900
         "Give a monkey the tools and he'll build a typewriter."

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at ic.ac.uk
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo at ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)




More information about the Xml-dev mailing list