开发者

Wrap XML tags (insert around existing xml data) in xquery for eXist

开发者 https://www.devze.com 2023-03-09 15:15 出处:网络
Can anyone please help me with this xquery for eXist database. I have the following xml s开发者_如何学JAVAtructure

Can anyone please help me with this xquery for eXist database. I have the following xml s开发者_如何学JAVAtructure

<A>  
   <B>  
     <D/>  
     <D/>  
     <D/>  
     <E/>  
  </B>  
</A> 

I'm trying to get the following structure

<A>  
   <B>  
    <C>  
     <D/>  
     <D/>  
     <D/>  
     <E/>   
    </C>   
  </B>  
</A>

How do I insert the <C> tag?

Thanks

--SD


I can't verify, but it should be so:

let $x := doc('namedocument.xml')/A/B
update insert <C>$x</C> into  doc('namedocument.xml')/A/B


You don't need XQuery Update to do this kind of operations.

This XQuery application:

<A>
 <B>
  <C>
  {for $n in /A/B/node()
   return $n}
  </C> 
 </B>
</A>

when applied on the provided XML document:

<A>      
  <B>
    <D/>
    <D/>
    <D/>
    <E/>
  </B>   
</A>  

produces exactly the wanted, correct result:

<A>
   <B>
      <C>
         <D/>
         <D/>
         <D/>
         <E/>
      </C>
   </B>
</A>
0

精彩评论

暂无评论...
验证码 换一张
取 消