[xquery-talk] XQuery Update: replacing element content with a sequence of nodes

Andrew Welch andrew.j.welch at gmail.com
Mon Apr 11 10:23:52 PDT 2011


On 8 April 2011 19:48, Florent Georges <lists at fgeorges.org> wrote:
>  Hi,
>
>  I have to replace the content of an element containing text
> with two sub elements, using XQuery Update.  The input looks
> like:
>
>    <parent>hello world</parent>
>
> and I'd like to change it to (I added some indentation only for
> readability):
>
>    <parent>
>       <one/>
>       <two/>
>    </parent>
>
>  I use the following expression:
>
>    replace node parent/text() with (<one/>, <two/>)
>
>  This works, but this is fragile, depending on the exact content
> of the parent element.

how about replacing the parent node itself instead:

replace node parent with <parent><one/><two/></parent>


-- 
Andrew Welch
http://andrewjwelch.com



More information about the talk mailing list