Bug 21025 - [XQ 3.0] copying unused namespace declarations
Summary: [XQ 3.0] copying unused namespace declarations
Alias: None
Product: XPath / XQuery / XSLT
Classification: Unclassified
Component: XQuery 3.0 (show other bugs)
Version: Working drafts
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: Jonathan Robie
QA Contact: Mailing list for public feedback on specs from XSL and XML Query WGs
Depends on:
Reported: 2013-02-17 11:00 UTC by Nikolay Ognyanov
Modified: 2013-05-09 19:43 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Ognyanov 2013-02-17 11:00:44 UTC
It seems to me that the draft specs do not provide a way to copy "unused" (i.e. such that no element in the documet resides in those) namespace declarations from a processed xml document. There are however important use cases where such feature is needed. For example xml schema documents often require declaration of default namespace even though the elements of the schema itself all reside in the xs: namespace. The namespace axis in combination with computed namespace constructors would solve this but namespace axix is explicitely not supported. Am I missing an alternative solution or is the use case truly not supported? If so then I would advocate strongly for its support since processing of xml schema documents is hardly an insignificant use case.


P.S.: For examples of xml schemas where copying of the default namespace is mandatory you can look e.g. at http://www.opentravel.org/Specifications/Default.aspx
Comment 1 Michael Kay 2013-02-17 11:18:31 UTC
Personal response: I agree there are many use cases where this would be convenient, and indeed where the namespace axis would be convenient. However, there is a workaround in 3.0 (unlike 1.0) which will have to do for now: you can use 


to "reconstruct" the namespace nodes for element $e that you would have found using the namespace axis if it were available.
Comment 2 Nikolay Ognyanov 2013-02-17 12:33:39 UTC
Mea culpa! Your suggestion works (except for the order of arguments of namespace-uri-for-prefix) and I have missed this workaround. I am afraid though that many other users of xquery 3.0 will miss it too. Therefore I would like to modify this filing into a suggestion to improve the draft documentation to point out more explicitely what alternatives to the namespace axis are provided.

Comment 3 Jonathan Robie 2013-03-19 17:08:31 UTC
(In reply to comment #1)

> in-scope-prefixes($e)!namespace-node(){.}{namespace-uri-for-prefix($e,.)}

I was confused by "namespace-node()" in the above example. The correct syntax is:

in-scope-prefixes($e) ! namespace {namespace-uri-for-prefix($e,.)} {.}

This is editorial; I do think an example would be helpful.
Comment 4 Jonathan Robie 2013-05-09 19:43:13 UTC
I just checked in the example for the XQuery specification.