[xquery-talk] Default namespace best practices?
mhk at mhk.me.uk
Wed Mar 9 16:42:18 PST 2005
> Is this a requirement, or is it implementation-dependent? Given the
> declare namespace x = "someURI";
> <x:foo xmlns="someURI">
> Saxon 8.1B returns (omitting XML declaration)
> <x:foo xmlns="someURI" xmlns:x="someURI">
> whereas, for example, the Mark Logic XML server returns
> <foo xmlns="someURI">
> Is that kosher?
No, it's not. See http://www.w3.org/TR/xquery/#id-element-constructor
"If the element name in a direct element constructor has a namespace prefix,
the namespace prefix is resolved to a namespace URI using the statically
known namespaces. If the element name has no namespace prefix, it is
implicitly qualified by the default element/type namespace. Note that both
the statically known namespaces and the default element/type namespace may
be affected by namespace declaration attributes found inside the element
constructor. The namespace prefix of the element name is retained after
expansion of the QName, as described in [XQuery 1.0 and XPath 2.0 Data
Model]. The resulting expanded QName becomes the name of the constructed
(The definition of "expanded QName" is now a triple, containing local name,
namespace URI, and prefix).
The spec changed fairly recently to require prefix retention wherever
possible, so Mark Logic may not have caught up with the changes. The main
reason for the change was concerned with attribute nodes rather than
elements - parentless attributes exist independently of any namespace
declarations - but the change was made uniformly for symmetry.
More information about the talk