OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: DOM level 2: creating elements/attributes in namespaces withutprefix



Here's a slightly more "offical" reply from the DOM working group:

A serializer may have to fix up prefixes and/or insert additional
declarations. We're working on a proposal for a standard way to do that; see
DOM Level 3 Core WD for a slightly obsolete sketch of a normalizeNS()
method:

"This method walks down the tree, starting from this node, and adds
namespace declarations where needed so that every namespace being used is
properly declared. It also changes or assign prefixes when needed. This
effectively makes this node subtree is "namespace wellformed".
What the generated prefixes are and/or how prefixes are changed to achieve
this is implementation dependent"

We are working on an improved version of that sketch, and plan to publish an
algorithm that that should make the behavior less implementation-dependent.
Meanwhile, anything which produces a document having the correct semantics
is, by definition, a correct serialization; if you don't like having the
serializer muck with your document, make it all namespace-well-formed
_before_ you serialize. That is, add "attributes" (the DOM doesn't yet
distinguish attributes from namespace declarations) in the appropriate
places to either associate the namespace of the new elements with a prefix,
or specify a default namespace.

<personal_comment>The root of the problem here is that the various
XML-related specs have different conceptions of what namespaces really mean
for the information in an XML document.  Some treat prefixes as "syntax
sugar" (DOM Level 2), some don't (Canonical XML); XPath/XSLT imply that
every node has a namespace URI property, whereas the DOM models the syntax
more literally and treats namespace declarations as attributes on the
elements where they are declared.  This really will be straightened out
someday (DOM 3 or 4 / XPath 2 ???) ... in the meantime, it takes great care
to work with namespaces in applications that employ multiple W3C specs at
once, e.g., DOM, Canonical XML, XSLT. </personal_comment>