LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives

XML-L Archives

XML-L Archives


Next Message | Previous Message
Next in Topic | Previous in Topic
Next by Same Author | Previous by Same Author
Chronologically | Most Recent First
Proportional Font | Monospaced Font


Join or Leave XML-L
Reply | Post New Message
Search Archives

Subject: Re: <p xmlns=''>
From: "John E. Simpson" <[log in to unmask]>
Reply-To:General discussion of Extensible Markup Language <[log in to unmask]>
Date:Wed, 20 Jun 2001 09:04:13 -0400

text/plain (81 lines)

Jacob Palme wrote:

> ...[snip]...
>       <notes>
>         <!-- make HTML the default namespace for a hypertext
> commentary -->
>         <p xmlns=''>
>             This is also available <a
> href="">online</a>.
>         </p>
>       </notes>
> Question 1: If <notes> includes several paragraphs, do I have
> to repeat <p xmlns=''> for every
> <p> tag within <notes>?
> Question 2: Would it be possible to <notes
> xmlns='>, so that this need not
> be repeated multiple times in the XHTML text?

A namespace will be inherited by all descendants of the element
declaring the namespace (until and unless some descendant declares a
different namespace for the same prefix, which would be very unusual --
even then, it would be in effect only for the scope of the declaring

There is no "inherited by following siblings" rule for namespace
declarations, though. So if (per your question 1) the notes element
contained several p's, you couldn't declare it on the first p and have
that declaration "trickle sideways" to subsequent ones. You'd have to
declare it on every p (though not on elements *contained* by those p's).

There's one big potential problem with your question 2. A namespace
declaration is in effect not just for descendants of the declaring
element, but for that element itself. So if you do:
   <notes xmlns=''>
you've got a problem. Namely (pun intended :), the declaration declares
that all UNprefixed names in scope for the notes element (including the
notes element itself) are in the XHTML namespace. But an element named
"notes" does *not* lie within that namespace, which would therefore
cause it to be rejected by any processor which "knows about" that namespace.

So you've got two choices:

(1) You can declare the namespace in the notes element's start tag, as
long as you've distinguished *its* namespace from the namespace in
effect for its descendants by using a prefix on either the notes
element's name, or on the descendants. E.g., either:
    <notes xmlns:xhtml=''>
    <jp:notes xmlns=''

(2) You can insert, as a child of the notes element, an additional
"ghost" element which really *is* from the XHTML namespace, and declare
that namespace in that element. I say it's a "ghost" element because you
don't want to choose an element type (e.g., p itself) which has any real
meaning other than containership. As it happens, there's an XHTML
element ideally suited for this -- the div element. So you'd do this:
       <div xmlns=''>
Option (2) suits my taste much more than option (1), which forces a
wholly artificial namespace prefix to be declared on either the outer or
the inner structure (and hence may "break" any application expecting to
find the element names sans prefixes).

John E. Simpson          | "I just got out of the hospital. I was in a    | speed reading accident. I hit a bookmark and
XML Q&A:     | flew across the room." (Steven Wright)

Back to: Top of Message | Previous Page | Main XML-L Page



CataList Email List Search Powered by the LISTSERV Email List Manager