XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Tony ZanellaSubject: 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:

<doc href="/home/tony/Desktop/collections/18cent_c/18cent_c.01.xml"/>
<doc href="/home/tony/Desktop/collections/18cent_c/18cent_c.02.xml"/>

and gives me a nice list of the head tags, which I name "results.xml":

<head>Note </head>
<head>Chapter VII </head>
<head>Title Page </head>

Then, I process "results.xml" with a regex to tag up roman numerals, like so, and save the file:

<head>Note </head>
<head>Chapter <roman_num>VII</roman_num> </head>
<head>Title Page </head>

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

Minollo I.Subject: Swapping elements using XQuery?
Author: Minollo I.
Date: 06 Oct 2008 10:57 AM
Looks like you are relying on a proprietary handling of the collection() function (http://www.saxonica.com/documentation/sourcedocs/collections.html). I would suggest that you ask the question to saxonica.com directly.

Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.