Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] Scope of namespaces

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: "Michael Kay" <mike AT saxonica.com>
  • To: "'Elliotte Harold'" <elharo AT metalab.unc.edu>
  • Cc: 'xom-interest' <xom-interest AT lists.ibiblio.org>
  • Subject: Re: [XOM-interest] Scope of namespaces
  • Date: Mon, 6 Feb 2006 11:45:57 -0000

> If XOM were religious about implementing the model I think it would
> become unusable. For instance consider this:
>
> Element root = new Element("foo:name", "http://www.example.org/";);
> root.addNamespaceDeclaration("bar", "http://www.example.com/";);
> Element child = new Element("child");
> root.appendChild(child);
>
> If were to follow the XPath model directly then what we'd
> have would be:
>
> <foo:name xmlns:foo="http://www.example.org/";
> xmlns:bar="http://www.example.com/";>
> <child xmlns:foo="" xmlns:bar=""/>
> </root>
>

If you look at XSLT 2.0 and XQuery 1.0, when you copy an element (which you
need to do if you want to attach it to a new parent) then there are two
options: copy-namespaces and inherit-namespaces. The first option indicates
whether all the existing in-scope namespaces of the element are copied (if
not, only the namespaces actually used in element and attribute names are
copied). The second option indicates whether the element inherits the
in-scope namespaces of the new parent. The default in XSLT 2.0 (and the only
option in 1.0) is copy="yes", inherit="yes". This default avoids the need
for the namespace undeclarations in your example (which are in any case
permitted only in XML 1.1).

Michael Kay






Archive powered by MHonArc 2.6.24.

Top of Page