[JDEV] namespaces, cont.
C. Scott Ananian
cananian at lesser-magoo.lcs.mit.edu
Tue Dec 21 15:16:24 CST 1999
-----BEGIN PGP SIGNED MESSAGE-----
On Tue, 21 Dec 1999, C. Scott Ananian wrote:
> However, *anything* can be included inside the <x> tag, and by convention
> that anything is a valid XML document in the namespace given by the xmlns
> attribute.
Thinking about this, I should have said:
"by convention that 'anything' is a valid XML document *conforming to
the DTD* specified in the xmlns attribute."
The fact that all interior tags are in a different namespace is important
when evaluating validity and such, but the key to interpreting the
contents is to go off and fetch the DTD specified. The *namespace*
specification doesn't require that the contents of the xmlns attribute
point to a DTD; xmlns="foo" and xmlns="http://slashdot.org" are quite
acceptable from the *namespace validity* standpoint, even though they
don't give you any information at all about how to interpret the contents
of the <x> tag.
Also, given a close reading of the name-space spec, it should be understood
that the namespaces of http://protocol.jabber.org/ns.html are ill-defined.
The real 'namespace's defined should be canonical URL pointing to DTDs for,
say, the client authorization protocol. The namespace you want to use,
according to W3C recommentations, is
http://protocol.jabber.org/jabber:iq:auth/auth.dtd
(i.e., a URI), *not*
jabber:iq:auth
If I want to refer to an element as
<jabber:iq:auth:query>
I just set the following attribute (in the query tag or any enclosing)
xmlns:jabber:iq:auth="http://protocol.jabber.org/jabber:iq:auth/auth.dtd"
The actual "universal name" of the tag (using James Clark's syntax) is
then
{http://protocol.jabber.org/jabber:iq:auth/auth.dtd}query
With all this in mind, we can see how the examples at
http://protocol.jabber.org/jabber:iq:auth/examples.txt are
incorrect. I'll repeat the first one here:
<iq type="set">
<query xmlns="jabber:iq:auth">
<username>foo</username>
<password>bar</password>
<resource>FooBarGuy</resource>
</query>
</iq>
Now, the <iq> tag can only have <query> as a member. But as written above,
the <iq> tag has a member called <{jabber:iq:auth}query>, which is *not*
in the DTD --- only the default-namespace <query> tag is in the DTD. The
example is thus not valid XML. We could rewrite it as:
<iq type="set">
<query xmlns:auth="http://protocol.jabber.org/jabber:iq:auth/auth.dtd">
<auth:username>foo</auth:username>
<auth:password>bar</auth:password>
<auth:resource>FooBarGuy</auth:resource>
</query>
</iq>
where the desired interpretation of the <query> tag is that the
contents form a valid XML document using the DTD specified by the xmlns
attribute.
An alternative is to change the DTD for the server protocol such that
<iq> just encapsulates #PCDATA (no interior <query> tags) -- but then it
becomes very difficult to specify precisely how the contents of the <iq>
tag should be interpreted (the contents don't stand-alone as a valid XML
document any more, because there's no DTD specified).
It might be mentioned that Bert Bos has made an effort at a formal
definition for nested XML documents that uses <!doctype> instead of
relying on namespace hacks. What detail there is on this is found at
http://www.w3.org/XML/simple-XML.html
Work on XML-Schema (the eventual replacement for DTDs) also tries to
handle extensibility in a cleaner manner. For example, the XML-Data
proposal submitted to the XML-Schema working group allows 'open content
models' (http://www.w3.org/TR/1998/NOTE-XML-data-0105/#OpenClosed).
But for now standard XML and namespace hacks are the way to go.
--s
@ @
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-oOO-(_)-OOo-=-=-=-=-=
C. Scott Ananian: cananian at lcs.mit.edu / Declare the Truth boldly and
Laboratory for Computer Science/Crypto / without hindrance.
Massachusetts Institute of Technology /META-PARRESIAS AKOLUTOS:Acts 28:31
-.-. .-.. .. ..-. ..-. --- .-. -.. ... -.-. --- - - .- -. .- -. .. .- -.
PGP key available via finger and from http://www.pdos.lcs.mit.edu/~cananian
Flintlock COBRA JANE operation Shoal Bay General Israel planning SEAL Team 6
Justice pending insurgent Delta Force fissionable immediate Minister
-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
iQCVAwUBOF/uL73Z92aFrZ7tAQFaEgP+MF9N/NTuM33KFaEZEUZYWUQmmULjcs0X
EpaKenuRCIdTiRLXFB03xt/xvmJ2fl6nXriG+b49D0Lzl4GRPZGTvZtow7C+lASX
UYphXB427HV6EO8+t33MmrDJ3f7LZeZrif+yxTV1d3qoj9zqWlQmdnvGHtwPfeWz
hzYVrHvVJ7g=
=ovxX
-----END PGP SIGNATURE-----
More information about the JDev
mailing list