Getting superfluous namespace declaration on XQuery result
Added by Martin Honnen about 7 years ago
Using Saxon 9.8.0.4 HE or EE and an XQuery from the command line where I try to recreate the root element from the input document, then add two nested elements with direct element constructors to contain some descendants elements of the original document I get duplicated namespace declarations on the descendant elements.
Here is a reduced test case:
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare default element namespace "http://example.com/ns1"; declare option output:indent "yes"; /*/element {node-name()} { let $root := . return in-scope-prefixes(.)!namespace {.} {namespace-uri-for-prefix(., $root)}, @*,{ //item }}
A sample input document is
a
b
The result I get with Saxon is
a
b
so the @item@ elements have @xmlns:xsi@ namespace declarations they don't need.
Using XmlPrime or Altova XMLSpy the result is simply
a
b
so this seems some oddity of Saxon.
Interestingly enough, when trying to reduce the problem a bit more to only have on direct element constructor
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization"; declare default element namespace "http://example.com/ns1"; declare option output:indent "yes"; /*/element {node-name()} { let $root := . return in-scope-prefixes(.)!namespace {.} {namespace-uri-for-prefix(., $root)}, @*, { //item } }
Saxon gives the same result as XmlPrime or Altova and the @item@ elements don't have the additional namespace declarations:
a
b
Please register to reply