|
next
|
Subject: Swapping elements using XQuery? Author: Tony Zanella Date: 06 Oct 2008 10:13 AM
|
Hello all,
I'm using the following XQuery to list all the "head" elements in a collection of xml files, nesting them in a "results" element:
<results>{for $x in collection("collection_list.xml")//head return ($x)}</results>
This goes into "collection_list.xml", which looks like:
<collection>
<doc href="/home/tony/Desktop/collections/18cent_c/18cent_c.01.xml"/>
<doc href="/home/tony/Desktop/collections/18cent_c/18cent_c.02.xml"/>
...
</collection>
and gives me a nice list of the head tags, which I name "results.xml":
<results>
<head>Note </head>
<head>Chapter VII </head>
<head>Title Page </head>
...
</results>
Then, I process "results.xml" with a regex to tag up roman numerals, like so, and save the file:
<results>
<head>Note </head>
<head>Chapter <roman_num>VII</roman_num> </head>
<head>Title Page </head>
...
</results>
Now, what I want to do is to swap out the "head" elements in the collection (18cent.01.xml, etc.), replacing them with the "head" elements in "results.xml".
Is this possible using XQuery? If so, how? If not, can you suggest another way of achieving this?
Thanks in advance for your help!
Tony Zanella
|
|
|