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
Conferences Close Tree View
+ Stylus Studio Feature Requests (1175)
+ Stylus Studio Technical Forum (14520)
+ Website Feedback (247)
+ XSLT Help and Discussion (7600)
- XQuery Help and Discussion (1944)
-> + What path notation works when ... (6)
-> - Xquery Exception (1)
-> + [java] [Fatal Error] Test.xml:... (2)
-> + unable to produce correct XML ... (2)
-> + where can I find stylusxql uti... (3)
-> + Trouble Mapping Multiple Eleme... (3)
-> - input parameter (1)
-> - set element value (1)
-> + Xquery Performance Issue (21)
-> + Run Xquery Program using Java (4)
-> + XQuery XML to CSV (3)
-> + XQuery MySQL connector (4)
-> + XQuery with JDBC connection is... (3)
-> + Create FTP Server (2)
-> + XQuery Nested Loop Lookup (5)
-> + Xpath using a Variable for [@I... (2)
-> - My xqDoc option is disabled. (1)
-> + Xpath ancestor selection (4)
-> + Exception: sequence of more th... (2)
-> + XQUF usage (3)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
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:

<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


Posttop
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.

   
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!  
go

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.