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
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
john jenkinsonSubject: XSL SORTING PROBLEM !!
Author: john jenkinson
Date: 09 May 2007 08:59 AM
Originally Posted: 08 May 2007 10:08 AM
Hi

I am trying to sort a xml file using xslt in order to display the lowest RoomPrice for each Hotel node in order i.e if a Hotel has a RoomPrice of £49 and another RoomPrice of £59 (same Hotel) it should then put the one with £49 first. There are also mulitple Hotels and these should be sorted on lowest RoomPrice within each Hotel.
If anyone could help it would be of great benefit to me.

Here is my XML :

<Hotel h="1">
<HotelCode>LGWARO</HotelCode>
<HotelName>Arora International</HotelName>
<StarRating>4</StarRating>
<OnAirport>N</OnAirport>
<NonSmokingRooms>N</NonSmokingRooms>
<Transfer24Hour>N</Transfer24Hour>
<CarParkOnSite>Y</CarParkOnSite>
<RequestFlags>
<Registration>N</Registration>
<CarMake>N</CarMake>
<CarModel>N</CarModel>
<CarColour>N</CarColour>
<CarPickupDate>N</CarPickupDate>
<CarDropoffTime>N</CarDropoffTime>
<CarPickupTime>N</CarPickupTime>
<CreditCard>N</CreditCard>
<ReturnFlight>N</ReturnFlight>
<Terminal>N</Terminal>
</RequestFlags>
<RoomType t="1">
<Room r="1">
<RoomCode>DBL</RoomCode>
<BoardBasis>RO</BoardBasis>
<Upgrade>N</Upgrade>
<Price p="1">
<ParkingDays>0</ParkingDays>
<RoomPrice>354.00</RoomPrice>
</Price>
<Price p="2">
<ParkingDays>8</ParkingDays>
<RoomPrice>384.00</RoomPrice>
</Price>
<Price p="3">
<ParkingDays>15</ParkingDays>
<RoomPrice>410.00</RoomPrice>
</Price>
</Room>
<Room r="2">
<RoomCode>TWN</RoomCode>
<BoardBasis>RO</BoardBasis>
<Upgrade>N</Upgrade>
<Price p="1">
<ParkingDays>0</ParkingDays>
<RoomPrice>354.00</RoomPrice>
</Price>
<Price p="2">
<ParkingDays>8</ParkingDays>
<RoomPrice>384.00</RoomPrice>
</Price>
<Price p="3">
<ParkingDays>15</ParkingDays>
<RoomPrice>410.00</RoomPrice>
</Price>
</Room>
</RoomType>
</Hotel>
<Hotel h="2">
<HotelCode>LGWARP</HotelCode>
<HotelName>Arora International (Sec-Pkg)</HotelName>
<StarRating>4</StarRating>
<OnAirport>N</OnAirport>
<NonSmokingRooms>N</NonSmokingRooms>
<Transfer24Hour>N</Transfer24Hour>
<CarParkOnSite>N</CarParkOnSite>
<RequestFlags>
<Registration>N</Registration>
<CarMake>N</CarMake>
<CarModel>N</CarModel>
<CarColour>N</CarColour>
<CarPickupDate>N</CarPickupDate>
<CarDropoffTime>N</CarDropoffTime>
<CarPickupTime>N</CarPickupTime>
<CreditCard>N</CreditCard>
<ReturnFlight>N</ReturnFlight>
<Terminal>N</Terminal>
</RequestFlags>
<RoomType t="1">
<Room r="1">
<RoomCode>DBL</RoomCode>
<BoardBasis>RO</BoardBasis>
<Upgrade>N</Upgrade>
<Price p="1">
<ParkingDays>8</ParkingDays>
<RoomPrice>630.00</RoomPrice>
</Price>
<Price p="2">
<ParkingDays>15</ParkingDays>
<RoomPrice>654.00</RoomPrice>
</Price>
</Room>
<Room r="2">
<RoomCode>TWN</RoomCode>
<BoardBasis>RO</BoardBasis>
<Upgrade>N</Upgrade>
<Price p="1">
<ParkingDays>8</ParkingDays>
<RoomPrice>630.00</RoomPrice>
</Price>
<Price p="2">
<ParkingDays>15</ParkingDays>
<RoomPrice>654.00</RoomPrice>
</Price>
</Room>
</RoomType>
</Hotel>
<Hotel h="3">
<HotelCode>LGWHIL</HotelCode>
<HotelName>Hilton</HotelName>
<StarRating>4</StarRating>
<OnAirport>Y</OnAirport>
<NonSmokingRooms>N</NonSmokingRooms>
<Transfer24Hour>Y</Transfer24Hour>
<CarParkOnSite>N</CarParkOnSite>
<RequestFlags>
<Registration>Y</Registration>
<CarMake>N</CarMake>
<CarModel>N</CarModel>
<CarColour>N</CarColour>
<CarPickupDate>Y</CarPickupDate>
<CarDropoffTime>Y</CarDropoffTime>
<CarPickupTime>Y</CarPickupTime>
<CreditCard>N</CreditCard>
<ReturnFlight>N</ReturnFlight>
<Terminal>Y</Terminal>
</RequestFlags>
<RoomType t="1">
<Room r="1">
<RoomCode>DBL</RoomCode>
<BoardBasis>RO</BoardBasis>
<Upgrade>Y</Upgrade>
<Price p="1">
<ParkingDays>0</ParkingDays>
<RoomPrice>810.78</RoomPrice>
</Price>
<Price p="2">
<ParkingDays>8</ParkingDays>
<RoomPrice>834.65</RoomPrice>
</Price>
<Price p="3">
<ParkingDays>15</ParkingDays>
<RoomPrice>864.65</RoomPrice>
</Price>
</Room>
<Room r="2">
<RoomCode>TWN</RoomCode>
<BoardBasis>RO</BoardBasis>
<Upgrade>Y</Upgrade>
<Price p="1">
<ParkingDays>0</ParkingDays>
<RoomPrice>810.78</RoomPrice>
</Price>
<Price p="2">
<ParkingDays>8</ParkingDays>
<RoomPrice>834.65</RoomPrice>
</Price>
<Price p="3">
<ParkingDays>15</ParkingDays>
<RoomPrice>864.65</RoomPrice>
</Price>
</Room>
</RoomType>
</Hotel>

Cheers

John

Postnext
Elias HuterSubject: XSL SORTING PROBLEM !!
Author: Elias Huter
Date: 09 May 2007 03:29 AM
Originally Posted: 09 May 2007 03:14 AM
I wrapped the source and the result in an "Envelope" Tag so everything will work fine.

Find the solution attached.


Documentroomprice(1).xsl
Sort by Roomprice ascending

Postnext
john jenkinsonSubject: XSL SORTING PROBLEM !!
Author: john jenkinson
Date: 09 May 2007 06:32 AM
Thanks for the reply Elias.

Unfortunatley there can be more than 1 room in the xml. Hence the sorting needs to work on each room.

Therefore the sorting order I need is this:

1) Find lowest RoomPrice per room, then sort rooms.
2) Then sort Hotels on lowest RoomPrice in any room per Hotel.

I hope you can assist further.

Many thanks

John

Postnext
Elias HuterSubject: XSL SORTING PROBLEM !!
Author: Elias Huter
Date: 09 May 2007 08:24 AM
Originally Posted: 09 May 2007 07:47 AM
- Can there be more than one "RoomType" Node per "Hotel" node, or only mutliple "Room" Nodes?
- Must the prices per Room also be sorted or only the rooms and afterwards the hotels?
- Can you use XSLT 2.0 or only XSLT 1.0?

Postnext
john jenkinsonSubject: XSL SORTING PROBLEM !!
Author: john jenkinson
Date: 09 May 2007 09:13 AM
Originally Posted: 09 May 2007 09:07 AM
There is generally only one RoomType but there can be more than one RoomType (max 2). Each Hotel should be sorted by the lowest RoomPrice of any of it's rooms. The rooms should also be sorted by the lowestPrice per room.
XSL 1.0 is being used at the moment

Postnext
Elias HuterSubject: XSL SORTING PROBLEM !!
Author: Elias Huter
Date: 09 May 2007 09:36 AM
But can you (your parser) use XSLT 2.0? I think the use of the min() function would help alot but it's only available in XSLT 2.0

Postnext
john jenkinsonSubject: XSL SORTING PROBLEM !!
Author: john jenkinson
Date: 09 May 2007 09:56 AM
It's xsl 1.0 only at the mo

Postnext
Elias HuterSubject: XSL SORTING PROBLEM !!
Author: Elias Huter
Date: 09 May 2007 10:32 AM
I'm sorry, I dont see a XSLT 1.0 solution although there might be one. Nontheless I acomplished to make a XSLT 2.0 solution, maybe it helps you or shows you a direction how to solve your problem.

Be aware that I tested the XSL a bit and it seems to work, please test it thoroughly anyway if you plan to use it.


Documentroomprice_xslt2.xsl
XSLT2, Sort: Hotel, RoomType, Room, Pric

Posttop
Tony LavinioSubject: XSL SORTING PROBLEM !!
Author: Tony Lavinio
Date: 11 May 2007 10:09 AM
General XSLT questions are best asked on the xsl-list run by
Mulberry Technologies. There experts with varied experiences
are often eager to help.

 
Topic Page 1 2 3 4 5 6 7 8 9 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.