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 (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
+ XSLT Help and Discussion (7625)
- XQuery Help and Discussion (2017)
-> + Issue with Processing Instruct... (2)
-> + problem converting json to XML... (2)
-> + Problem base64 decoding string... (3)
-> + Problems posting multipart for... (5)
-> + trouble with download of price... (2)
-> + Problem with http-post not bei... (3)
-> + path problem, xps_file:writeAl... (9)
-> + Xquery update support? (2)
-> + problem with Stylus studio try... (5)
-> + adding dtd reference to xml ou... (4)
-> + xquery escaping ambarsand when... (3)
-> + Whitespace problem when return... (5)
-> + Problem with namespace prefix ... (5)
-> - Sending via SFTP returns unexp... (1)
-> + Query and Sftp clent (4)
-> + xquery and try - catch (3)
-> + Query + ddtek:http-post optio... (5)
-> + Example files referenced in do... (3)
-> + Automatic Error Detection and ... (3)
-> + Working with result of ddtek:h... (2)
-- [1-20] [21-40] [41-60] Next
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
ina robisSubject: XQUERY Newbie question
Author: ina robis
Date: 20 Jul 2006 10:58 AM
Hey all,

I am newbie in XQUERY I would like to query my xml file.
I have this piece of xml file


<TEST>
<TableID>
<ID>1</ID>
<roomName>Suite</roomName>
<TableRoom>
<ID>1</ID>
<A> 100
<Date>31.07.2005</Date>
</A>
</TableRoom>
<TableRoom>
<ID>1</ID>
<A>411
<Date>31.08.2005</Date>
</A><TableRoom>
<TableRoom>
<ID>1</ID>
<B>462
<Date>31.07.2005</Date>
</B>
</TableRoom>


I would like to have something of this kind (put in commun the date )


<TEST>
<TableID>
<ID>1</ID>
<roomName>Suite</roomName>
<TableRoom>
<ID>1</ID>
<Date>31.07.2005</Date>
<A> 100</A>
<B>462</B>
</TableRoom>
<TableRoom>
<ID>1</ID>
<Date>31.08.2005</Date>
<A>411</A>
<T/ableRoom> There is no info for B


this is my xquery code


<TEST>
{
for $i in doc("transformXQUERY.xml")//TableID/TableRoom,
$TableRoom in $i,
$a in $TableRoom/A
(:$b in $TableRoom/B
where $a/Date = $b/Date:) I have a problem here
order by $TableRoom/ID
return


<TableID>
{$i/ID}
{$a}
{$i/B}
</TableID>
}
</TEST>


any suggestions/ help


ina


Postnext
Ivan PedruzziSubject: XQUERY Newbie question
Author: Ivan Pedruzzi
Date: 08 Aug 2006 07:23 AM
Try the following

declare variable $in := doc("tableroom.xml");
declare variable $dates := distinct-values($in//Date/text());
declare variable $root := $in/*[1];

element { name($root) }
{
for $TableID in $root/*
return
element {name($TableID)} {
(
$TableID/ID,
$TableID/roomName,
for $date in $dates
return
<TableRoom>
{
<date>{$date}</date>,
for $room in $TableID/TableRoom
where $room//Date = $date
return
element {name($room)} {
$room/A/text() | $room/B/text()
}
}
</TableRoom>
)
}
}

Hope this helps
Ivan Pedruzzi
Stylus Studio Team

Posttop
ina robisSubject: XQUERY Newbie question
Author: ina robis
Date: 16 Aug 2006 04:46 AM
thank you sorry for this delay. Really helpful.

Ina

   
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.