Namespaces hate validation!
cowan at locke.ccil.org
Wed Jan 6 16:13:22 GMT 1999
Murray Maloney wrote:
> Everything that follows this point is predicated on the
> assumption that one can have such a DTD, but later Tim
> makes it clear that it is not currently feasible to design
> such a DTD.
Au contraire: we of DDML (formerly XSchema) *have* designed such
a DTD. The DDML DTD uses two namespaces, DDML and IBTWSH (which
latter does not use prefixes, in the name of HTML compatibility,
but is a true namespace anyway).
What we do not have is a *algorithmic* way of building such a
DTD. I doubt we ever will, as *judgment* is required to decide
when elements imported from other namespaces are to be allowed.
Merging two DTDs intelligently is no easier (but no harder, IMHO) than
designing content models in the first place: an "AI-complete" problem.
> >5. You preprocess the DTD, rewriting all the element & attribute
> > declarations with the appropriate prefixes
> Using special care to take into account the non-XML notion
> of "global attributes".
There is nothing particular about global attributes: from a
purely XML 1.0 viewpoint, they are ordinary attributes that happen
to have a ":" in their names. Their prefixes must be munged
just like element prefixes.
> >6. You preprocess the instance, making all namespace prefixes
> > explicit (no defaulting), declaring all the namespaces on the root
> > element, and using the same set of prefixes you used in the DTD
> Of course, this will not work for instances that redeclare
> a namespace prefix with a different URI for the purposes
> of local scoping of namespaces. In that case, you have to
> declare namespaces on elements as you go.
Not at all. With appropriate renamings of prefixes, you can move
all nested prefixes out to the outermost element. For example:
which uses two different namespaces with the prefix "foo",
can be rewritten without loss of generality as:
<root xmlns:foo1="http://yadda.yadda" xmlns:foo2="http://bongo.bongo">
> [Y]ou would have to inspect the entire document to determine
> whether local scoping of namespaces has been applied [...].
So you would. But nothing says Tim's algorithm can't be two-pass,
as indeed it must be: one pass to scan for namespace declarations,
and another pass to output the root element with all correctly
munged declarations and then all elements and attributes with
munged prefixes correctly applied. Given a tree API like the
DOM, it is not necessary (though it may be preferable) to actually
parse the instance twice.
> Well, tedious enough to make it unlikely that anyone will use
> validation on documents that utilize namespaces. It is hard.
> It is too hard.
It is hard until someone writes a tool to do it. I would do it
now if I had an easy-to-use DTD analyzer in Java.
> Murray Maloney, Esq. Phone: (905) 509-9120
> Muzmo Communication Inc. Fax: (905) 509-8637
> 671 Cowan Circle Email: murray at muzmo.com
Hmm. Pity I can't list my address as "Maloney Square" for
John Cowan http://www.ccil.org/~cowan cowan at ccil.org
You tollerday donsk? N. You tolkatiff scowegian? Nn.
You spigotty anglease? Nnn. You phonio saxo? Nnnn.
Clear all so! 'Tis a Jute.... (Finnegans Wake 16.5)
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;
To subscribe to the digests, mailto:majordomo at ic.ac.uk the following message;
List coordinator, Henry Rzepa (mailto:rzepa at ic.ac.uk)
More information about the Xml-dev