- From: Michael Kay <mhk@mhk.me.uk>
- Date: Fri, 13 Feb 2004 12:27:51 -0000
- To: "'Jonathan Robie'" <jonathan.robie@datadirect.com>, "'XML Query Comments'" <public-qt-comments@w3.org>
For information, XSLT 2.0 does provide these two options in its
xsl:copy-of instruction, for much the reasons described.
One use case that motivated this was the need to extract the payload of
a SOAP message without copying all the SOAP namespaces.
There is a complication, which James Clark identified: if you don't copy
the namespace nodes, you can't safely copy the type annotations.
Michael Kay
> -----Original Message-----
> From: public-qt-comments-request@w3.org
> [mailto:public-qt-comments-request@w3.org] On Behalf Of Jonathan Robie
> Sent: 13 February 2004 01:02
> To: XML Query Comments
> Subject: [XQuery] 3.7.4 Namespace nodes on constructed elements
>
>
>
> For many applications, namespace node preservation is
> overweight. For others, it is needed. The current definition
> of XQuery can easily result in large numbers of superfluous
> namespace nodes, especially when querying documents that use
> several namespaces.
>
> Consider the following data, taken from the DOM Issues List:
>
> <issues xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns:xi="http://www.w3.org/2001/XInclude"
> xmlns="http://www.w3.org/2003/10/issues"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
>
> <header>
> <title>DOM Level 3 Core Issues List</title>
> <!-- SNIP -->
> </header>
> </issues>
>
> Now consider the following query, applied to this data:
>
> <out>
> {
> doc("dom-issues.xml")/issues/header/title
> }
> </out>
>
> Here is the result, according to our current spec:
>
> <out>
> <title xmlns:xlink="http://www.w3.org/1999/xlink"
> xmlns:xi="http://www.w3.org/2001/XInclude"
> xmlns="http://www.w3.org/2003/10/issues"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> >DOM Level 3 Core Issues List</title>
> </out>
>
> Although none of these namespaces are actually used in the
> title element that was retrieved, our current specification
> require that all namespaces in scope in the original document
> must be in scope for the copied element in the constructed
> element. Now suppose that we create several
> namespace-decorated documents like this one, and perform an
> XQuery that copies from each of these to create a new
> document with even more namespaces...
>
> Naturally, we do need to ensure that namespaces are preserved
> if they are used in element names, attribute names, or
> QNames. Consider the following query:
>
> doc("dom-issues.xml")/issues//originator
>
> The result must preserve the above-mentioned namespaces to
> allow correct interpretation:
>
> <originator xlink:type='simple'
> xmlns:xlink="http://www.w3.org/1999/xlink"
> xlink:href="mailto:caillon@netscape.com">Christopher
> Aillon</originator>
>
> There are also XML vocabularies, such as XML Schema or XSLT,
> that use QNames in content, and for these, all QNames really
> must be preserved.
>
> I think we should provide two modes of operation:
>
> 1. Namespace preserving copy keeps all namespace nodes
>
> 2. Normal copy keeps only namespace nodes used in element names,
> attribute names, or instances of xs:QName.
>
> One possibility would be to declare this at a global level:
>
> declare namespace-preserving = "true";
>
> Another possibility would be to declare namespace
> preservation for specific namespaces:
>
> declare namespace-preserving = "http://www.w3.org/2001/XMLSchema",
> "http://www.w3.org/1999/XSL/Transform";
>
> Either of these would reduce the overhead associated with
> copying elements significantly in some implementation environments.
>
> Jonathan
>
Received on Friday, 13 February 2004 07:27:14 UTC