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

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