In that case then you could construct third node:

Let $new-xml :=
<chapters-source>
{$xmlNode1/chapter}
{$xmlNode2/chapter}
</chapters-source>

If what you're looking for is in-memory construction of nodes using functions 
like node-replace etc. you May wish to look at these threads:

http://markmail.org/thread/7zlmw3dpvkqnelly
http://markmail.org/thread/c5a3wqv2ukj3ugz5


and this commons contribution:

http://xqzone.marklogic.com/svn/commons/trunk/memupdate/

-fs

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Deshbir Singh 
Dugal
Sent: Monday, February 16, 2009 10:52 AM
To: 'General Mark Logic Developer Discussion'
Subject: RE: [MarkLogic Dev General] XQUERY question - Inserting nodesin 
memory

Hi Frank,

Appreciate the quick response.

Your solution assumes that $xmlNode1 & $xmlNode2 are literals; however this is 
not the case in my application, both these variable are initialized from 
documents stored in ML (using the document statement). In such a case I don't 
see how to apply your approach, unless I'm missing something.

I'm sorry if my earlier code snippet was misleading.

Regards,
Deshbir

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Frank Sanders
Sent: Monday, February 16, 2009 8:05 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] XQUERY question - Inserting nodes in 
memory

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


_______________________________________________
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