Re: Recursive replacement

Martin Probst <[email protected]> Mon, 30 Jan 2006 16:33:13 +0100
Newsgroups gmane.comp.web.query-languages
Organization X-Hive Corporation
Message-ID <[email protected]>
> > 2) for $p in fn:doc("test.xml")//a 
> >    do replace {$p}
> >       with element "new-node" {$p/*}
> 
> Hmm I'll leave that one for a WG member to answer.., I think that you
> should get get an error from
> http://www.w3.org/TR/xqupdate/#id-extensions-to-existing
> 
>   All the pending update lists generated by the previous step are merged
>   by successive invocations of the upd:mergeUpdates operation. If the
>   upd:mergeUpdates operation signals an incompatibility, a dynamic error
>   is raised [err:TBD].  
> 
> But I don't actually see that in the table in
> http://www.w3.org/TR/xqupdate/#id-compatibility
> which has side condition "Not compatible if t1 is t2." in some cases
> looks to me as if it should be t1 is an ancestor to t2

Well, the constructor "element new-node {$p/*}" copies the contents of
the node $p, so the outermost <a/> node is replaced with
<new-node><b><a/></b></new-node>.

There is also a rename operation for exactly this (changing a node name
without changing it's identity).

Martin