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

Florent Georges lists at fgeorges.org
Fri Apr 8 20:48:57 PDT 2011


  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.  For instance, that should generate an
error for the followin input (semantically identical to the above
example):

    <parent>hello <!-- -->world</parent>

  Is there any better way to do that?

  Regards,

-- 
Florent Georges
http://fgeorges.org/





More information about the talk mailing list