[JDEV] Namespaces
David Waite
mass at akuma.org
Thu Jul 11 08:56:31 CDT 2002
Kriggs wrote:
>If you would like to help me (by reading these 90 lines of text), try your
>best to correct me where I am wrong, and answer my questions (Lines marked
>with an asterisk (*) are points which I especially am having trouble with):
>
>1)
>
> <a xmlns="x:y">
> <b c="value1"/>
> </a>
>
>In this example, <a/>, <b/> and c="" are all using the x:y namespace. <b/>'s
>namespace is "x:y", just like <a/>'s, as opposed to my previous theory that
><b/>'s namespace becomes x:y:a.
>
Yep. Well, there is some debate over whether c="" is in a namespace at
all. the names recommendation does not clarify on this point until the
appendix, which is non-normative. Long discussion.
>* Would putting an x:y: prefix to every tag element's name do the same thing
>as the use of xmlns="x:y" in this example?
>
Incorrect.
1) You must use namespace prefixes to qualify an element not in the
default (non-prefixed) namespace. You cannot substitute a namespace URI
for said prefix. There isn't a standard for writing out "this element in
this namespace".
2) Prefixes cannot contain the ':' character anyways. (see
http://www.w3.org/TR/1999/REC-xml-names-19990114/#ns-decl)
>2)
>
> <a xmlns="http://..." xmlns:s="x:y">
> <s:b c="value1">
> <d/>
> <e s:f="value2"/>
> </s:b>
> </a>
>
>In this example,
><a/> is using the "http://..." website namespace
><b/> is using the x:y bulltin namespace because of the s: prefix
>c="" is using the x:y bulltin namespace because it is <b/>'s attribute.
><d/> is using the "http://..." website namespace, because it's prefix doesn't
>depend on it's parent's prefix.
><e/> is using the "http://..." website namespace for the same reason
>f="" is using the x:y bulltin namespace. Although normally an attribute
>inherits from it's parent, f="" has an s: prefix.
>
Other than the comment above on c="", sure.
>3)
>
> <a xmlns="v:w">
> <b xmlns="x:y">
> <s:c/>
> </b>
> </a>
>
><a/> has v:w as it's namespace
><b/> has x:y as it's namespace
>* <c/> has no namespace handler (?)
>
Yep.
>4)
>
>In a more explicit example:
>
> <stream:stream
> to="denmark"
> xmlns="jabber:client"
> xmlns:stream="http://etherx.jabber.org/streams">
> [...]
> <iq type="set" id="1">
> <query xmlns="jabber:iq:auth">
> <username>nick</username>
> <password>pass</password>
> <resource>home</resource>
> </query>
> </iq>
> [...]
> </stream:stream>
>
><stream:stream/> uses the xmlns:stream namespace (because of the stream:...
>part) looking for the element definition of "stream" (because of the
>...stream part)
>
You mean "http://etherx.jabber.org/streams" namespace.
><iq/>, having no prefix, defaults to the jabber:client namespace.
><query/>, <username/>, <password/> and <resource/> all take from
>jabber:iq:auth.
>
>
Yep.
>* Do I take it that jabber, despite the xml standard, applies xmlns:* to the
>level and lower, but applies xmlns only to the lower levels? Or does every
>jabber:iq:* contain <query/> in it's definition?
>
There was some confusion over the namespace spec. "query" as above is
not in the jabber:client namespace, even though it has been reported in
some documentation as thus before.
>* I notice that jabber:iq:auth has more than 1 colon (:). Is this only
>possible for namespaces, or can tag elements have that too (namespace
>declared like xmlns:a:b:c="name:space")? If so, how do you separate the
>element from the namespace? Is an actual element name not allowed to have any
>colons (:) in them?
>
Namespaces can have more than one colon, as they are URIs. A qualified
element or attribute name can only be qualified indirectly by a prefix,
not directly by a namespace.
-David Waite
More information about the JDev
mailing list