Deshbir,

All you have to do is select the relevant nodes, using XPath, from $xmlNode1, 
for inclusion in $xmlNode2. I think this will give you what you're asking for:

let $xmlNode1 :=
<chapters-source>
   <chapter>Chapter 1</chapter>
   <chapter>Chapter 2</chapter>
   <chapter>Chapter 3</chapter>
</chapters-source>

let $xmlNode2 :=
<chapters-destination>
   <chapter>Source Chapter 1</chapter>
   <chapter>Source Chapter 2</chapter>
   <chapter>Source Chapter 3</chapter>
   {$xmlNode1/chapter}
</chapters-destination>
return $xmlNode2

Hope this helps.

-fs

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Deshbir
Sent: Monday, February 16, 2009 8:56 AM
To: 'General Mark Logic Developer Discussion'
Subject: [MarkLogic Dev General] XQUERY question - Inserting nodes in memory

Hello All,

Could someone advise on the XQUERY syntax for inserting multiple nodes from 
one XQUERY variable into another. Following is a sample code depicting the 
problem.

#############################
let $xmlNode1 :=
<chapters-source>
   <chapter>Chapter 1</chapter>
   <chapter>Chapter 2</chapter>
   <chapter>Chapter 3</chapter>
   ..
   ..
   ..
</chapters-source>

let $xmlNode2 :=
<chapters-destination>
   <chapter>Source Chapter 1</chapter>
   <chapter>Source Chapter 2</chapter>
   <chapter>Source Chapter 3</chapter>
</chapters-destination>
.
.
##########################################################

All the <chapter> nodes that exist in $xmlNode1 need to be inserted into 
$xmlNode2 i.e. $xmlNode2 should end up as:

<chapters-destination>
   <chapter>Source Chapter 1</chapter>
   <chapter>Source Chapter 2</chapter>
   <chapter>Source Chapter 3</chapter>
   <chapter>Chapter 1</chapter>
   <chapter>Chapter 2</chapter>
   <chapter>Chapter 3</chapter>
   ..
   ..
   ..
</chapters-destination>

Thank you in advance.

Regards,
Deshbir



_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to