Bug #4661

Namespace constructor: conflicting default namespaces

Added by Christian Grün 12 months ago. Updated 3 months ago.

XQuery conformance
Start date:
Due date:
% Done:


Estimated time:
Legacy ID:
Applies to branch:
10, trunk
Fix Committed on Branch:
10, trunk
Fixed in Maintenance Release:


The following expression…

declare default element namespace 'ns';
  element a { namespace { '' } { 'ns2' } }

…yields a result:

<x xmlns="ns"><_0:a xmlns="ns2" xmlns:_0="ns"/></x>

This expression…

<x xmlns='ns'>{
  element a { namespace { '' } { 'ns2' } }

…raises an error (XTDE0430). Is that correct?


#1 Updated by Michael Kay 12 months ago

As far as I can see XQuery does not cover this situation and Saxon is following the XSLT rules, which do. It's not clear what other action is possible. You can't put the element in a different namespace, you can't give it a prefix bound to the null namespace, so you have to reject the namespace node as invalid.

There might be other outcomes that are consistent with the XQuery spec, but I think what Saxon is doing is reasonable.

#2 Updated by Christian Grün 12 months ago

Thanks for your assessment.

By intuition, I would have expected both expressions to yield the same result. But I didn’t find any clarification on this case in the spec either, and I doubt it will occur in practice anyway.

#3 Updated by Christian Grün 12 months ago

In addition, I noticed that element { ' a ' } {} returns < a />, while I would have expected an error. Considering your proposal in, a better alternative might be the normalization of whitespaces.

I can add a test case once we have decided for or against the error.

#4 Updated by Michael Kay 12 months ago

Whatever the phrase "If the atomized value of the name expression is of type xs:string or xs:untypedAtomic, that value is converted to an expanded QName." really means, I would expect any detailed rules to include first stripping whitespace, just as a cast operation does. Saxon is stripping whitespace to do the validation and is then erroneously using the original name as written. The bug (in XPathParser.makeNodeName()) is already fixed on the 10/11 branches, I will patch it now on 9.9 though I don't know if there will be another maintenance release on that branch,

#5 Updated by Michael Kay 11 months ago

  • Category set to XQuery conformance
  • Assignee set to Michael Kay

#6 Updated by Michael Kay 11 months ago

Discussed at team meeting. We felt that allowing URIQualifiedNames here was the right way to go, and if this meant defining new rules for the semantics of edge cases, we should go ahead and do this.

#7 Updated by Michael Kay 8 months ago

  • Status changed from New to Resolved
  • Priority changed from Low to Normal
  • Applies to branch 10, trunk added
  • Fix Committed on Branch 10, trunk added

I've reviewed the current state of this: new tests have been added, the product is passing the tests, and the new XQUery 4.0 draft clarifies the intended behaviour. Therefore closing.

#8 Updated by O'Neil Delpratt 3 months ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in Maintenance Release 10.5 added

Bug fix applied to Saxon 10.5 maintenance release.

Please register to edit this issue

Also available in: Atom PDF