[xquery-talk] Newbie Q: Namespace Handling
frans.englich at telia.com
Wed Jun 27 13:59:06 PDT 2007
On Thursday 03 May 2007 00:18, Michael Kay wrote:
> When you do
> <kml xmlns="http://earth.google.com/kml/2.1">
> the default namespace declaration affects the contained path expressions,
> so in
> you are selecting bar elements in namespace http://earth.google.com/kml/2.1
> There's a good reason XQuery was done this way, it was an attempt to avoid
> the problems that people have with default namespace handling in XSLT 1.0,
> where a default namespace declaration *doesn't* affect unprefixed names in
> path expressions. But it makes it very difficult to handle your scenario,
> where the source document is in no namespace but you want result elements
> to be in a default (unprefixed) namespace. In fact it's because of this
> scenario that XSLT 1.0 was designed the way it was...
> I think this is a serious usability problem with XQuery 1.0 as defined and
> it needs to be addressed in XQuery 1.1. (Please feel free to file this as a
> comment against the spec - they carry more weight when they come from
> In the meantime, I think your best option is probably to avoid using the
> default namespace in the result document: use a prefixed namespace instead.
> If you really need the result document to use the default namespace, then
> postprocess it to change the prefix.
> If you can't do that, some other possible workarounds are:
I've also experienced this now while writing queries(as opposed to
implementing XQuery) and this is indeed a severe usability issue. It's easy
to run into: generate an XHTML document from XML-data in a non-namespaced
format. The problem is all these browsers who fail parsing XHTML if a prefix
is in use.
It feels like a clean solution to setting the static properties would be
expressions that sets the properties for its child expression. For instance:
declare collation "mycollation"
The current solution is a global declaration, combined with local patches to
functions and expressions here and there, which it was believed to be
I think "local declaration scopes" would have been more expressive, safer(e.g,
not global, unless surrounding the top expression), made the spec simpler,
more in a functional style(?), and would have erased the above namespace
problem. Maybe I'm missing an obvious flaw in that approach, or perhaps
somethng like that could be used in 1.1.
Oh well, I guess this is a post of the kind of "This is how I would have
designed XML 2.0."
More information about the talk