[xquery-talk] Default namespace best practices?

Per Bothner per at bothner.com
Tue Mar 8 13:36:52 PST 2005

Michael Kay wrote:
> (a) if you define a default element namespace, then you have no simple way
> of referring to (or constructing) elements in the non-namespace.

It might be useful to be able to declare a prefix for an empty namespace:

declare namespace empty = "";
declare default element namespace xhtml = "....";
<foo/> (: in xhtml namespace :),
<empty:bar/> (: in no namespace :)

Unfortuntely, the latest draft says:
   If the URILiteral part of a namespace declaration is a zero-length string,
   any existing namespace binding for the given prefix is removed from the
   statically known namespaces.

This seems a less useful feature.

Alternatively, one could extend the syntax of QName to make the Prefix optional:
    QName ::= (Prefix? ':')? LocalPart
A missing prefix is in no namespace:
<:bar/> (: in no namespace :)
	--Per Bothner
per at bothner.com   http://per.bothner.com/

More information about the talk mailing list