[MarkLogic Dev General] XQUERY question - Inserting nodes in
memory
Frank Sanders
Frank.Sanders at marklogic.com
Mon Feb 16 06:34:46 PST 2009
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: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] 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
General at developer.marklogic.com
http://xqzone.com/mailman/listinfo/general
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4245 bytes
Desc: not available
Url : http://xqzone.marklogic.com/pipermail/general/attachments/20090216/876448ff/smime.bin
More information about the General
mailing list