[xquery-talk] copy-namespaces declaration - supported in Saxon? What about Zorba?
Chris Maloney
voldrani at gmail.com
Mon Apr 2 18:55:07 PDT 2012
Brilliant, it even makes sense! Here's what I came up with, which works.
xquery version "1.0";
declare copy-namespaces no-preserve, no-inherit;
for $f in doc("AppConfig.xml")//AppController/fleegle
return element { name($f) } { $f/(node() | @*) }
Thanks!
On Mon, Apr 2, 2012 at 6:42 PM, Michael Kay <mike at saxonica.com> wrote:
> The no-preserve and no-inherit options affect the namespaces acquired by a
> newly constructed element node. But your query isn't constructing a new
> element node, it is selecting an existing one. When you select an existing
> node, you get that node as is, and the node you have selected has these two
> namespaces in scope. To get rid of them, you will have to construct a new
> element that is the same as the original except for its namespaces.
>
> Michael Kay
> Saxonica
>
>
> On 02/04/2012 23:26, Chris Maloney wrote:
>>
>> Hi,
>>
>> I have this document:
>>
>> <AppConfig xmlns:paf="http://ncbi.gov/portal/paf"
>> xmlns:qs="http://ncbi.gov/portal/paf/querystring">
>> <AppController foo='bar'>
>> <fleegle/>
>> </AppController>
>> </AppConfig>
>>
>> which I'm processing with this XQuery:
>>
>> xquery version "1.0";
>> declare copy-namespaces no-preserve, no-inherit;
>> doc("AppConfig.xml")//AppController/fleegle
>>
>> and I'm getting this as output from Saxon PE 9.3:
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <fleegle xmlns:paf="http://ncbi.gov/portal/paf"
>> xmlns:qs="http://ncbi.gov/portal/paf/querystring"/>
>>
>> But I want to get rid of the unused namespace nodes, and I thought
>> "no-preserve" should do it.
>>
>> I found an email message from Michael Kay in Apr. 7, 2005, on the
>> saxon help list, in which he wrote:
>>
>> The basic functionality of copying an element without copying its
>> namespaces
>> is there in the product (and used in XSLT) but it's not yet wired
>> up to the syntax
>> of the query prolog. Sorry.
>>
>> Is it still not implemented, or am I doing something wrong?
>>
>> Can anybody tell me whether or not this is supported in Zorba?
>>
>> Thanks!
>>
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
More information about the talk
mailing list