Well, it's not ugly, it allows re-use of prefixes without creating
conflicts. This is the point of a local scoping mechanism. A prefix is
essentially a variable, bound to a URI. the draft allows these variables to
be rebound within limite hierachically nested scopes (just like all modern
programming languages). These scopes are in one-to-one correspondence with
the element structure of a document, which for documents is the most
relevant hierarchy.
It's true that DTDs cannot be aware of this right now, but it's also true
that local scoping is most useful incases where people want to add markup
to existing document intances (a key scenario for namespaces). It's also
true that after such dynamic markup, DTD validation is going to fail
anyway.
><!DOCTYPE A [
><!ELEMENT foo:A (B)>
><!ELEMENT B (#PCDATA, foo:A)*>
><!ATTLIST A xmlns:foo CDATA #IMPLIED>
><!ATTLIST B xmlns:foo CDATA #IMPLIED>
>]>
><foo:A xmlns:foo="[first URI]">
> <B xmlns:foo="[second URI]">
> <foo:A>
> <B>asdf</B>
> </foo:A>
> </B>
></foo:A>
>
>A more reasonable solution might be a namespace constraint that says that all
>DTD prefixes must be declared on the root element. However, without thinking
>this through too carefully, I suspect you lose a good deal of flexibility.
This very was considered very carefully by the SIG and the WG, and the
decision was taken that you did lose flexibility.
The document you give seems legal to me, although I'm not sure about the
use of #IMPLIED -- what is the status of the value of the xmlns attribute
of the second foo:A, given that there's no value in the instance, and no
default or fixed value?
I've not the time to track this down right now, but the effect of #IMPLIED
in attribute inheritance is worth checking, I think.
On the other hand, the following is unexceptional:
<!DOCTYPE A [
<!ELEMENT foo:A (B)>
<!ELEMENT B (#PCDATA, foo:A)*>
<!ATTLIST A xmlns:foo CDATA "[first URI]">
<!ATTLIST B xmlns:foo CDATA "[first URI]">
]>
<foo:A xmlns:foo="[first URI]">
<B xmlns:foo="[second URI]">
<foo:A>
<B>asdf</B>
</foo:A>
</B>
</foo:A>
The result of that is the following tree:
[first URI]:B
[second URI]:B
[second URI]:A
[second URI]:B
-- David
_________________________________________
David Durand dgd@cs.bu.edu \ david@dynamicDiagrams.com
Boston University Computer Science \ Sr. Analyst
http://www.cs.bu.edu/students/grads/dgd/ \ Dynamic Diagrams
--------------------------------------------\ http://www.dynamicDiagrams.com/
MAPA: mapping for the WWW \__________________________