LISTSERV mailing list manager LISTSERV 15.5

Help for XML-L Archives


XML-L Archives

XML-L Archives


View:

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

Options:

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


Subject: Re: <p xmlns='http://www.w3.org/1999/xhtml'>
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
Content-Type:text/plain
Parts/Attachments:
Parts/Attachments

text/plain (81 lines)


Jacob Palme wrote:

> ...[snip]...
>       <notes>
>         <!-- make HTML the default namespace for a hypertext
> commentary -->
>         <p xmlns='http://www.w3.org/1999/xhtml'>
>             This is also available <a
> href="http://www.w3.org/">online</a>.
>         </p>
>       </notes>
> Question 1: If <notes> includes several paragraphs, do I have
> to repeat <p xmlns='http://www.w3.org/1999/xhtml'> for every
> <p> tag within <notes>?
>
> Question 2: Would it be possible to <notes
> xmlns='http://www.w3.org/1999/xhtml>, 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
element).

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='http://www.w3.org/1999/xhtml'>
     ...
   </notes>
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='http://www.w3.org/1999/xhtml'>
       <xhtml:p>....</xhtml:p>
       ...
    </notes>
or:
    <jp:notes xmlns='http://www.w3.org/1999/xhtml'
       xmlns:jp='http://jacobpalmesnamespaceURI'>
       <p>...</p>
       ...
    </jp:notes>

(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:
    <notes>
       <div xmlns='http://www.w3.org/1999/xhtml'>
          <p>...</p>
          ...
       </div>
    </notes>
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
http://www.flixml.org    | speed reading accident. I hit a bookmark and
XML Q&A: www.xml.com     | flew across the room." (Steven Wright)

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

Permalink



LISTSERV.HEANET.IE

CataList Email List Search Powered by the LISTSERV Email List Manager