[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Complex Sorting Help

Subject: RE: Complex Sorting Help
From: "Crist, Trevor" <tcrist@xxxxxxxxxxxx>
Date: Sat, 25 Feb 2006 19:20:50 -0500
trevor re properties
Guess it's time to get that .NET Saxon so I've got XSLT 2.0. :-) Thanks.



> -----Original Message-----
> From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
> Sent: Saturday, February 25, 2006 7:12 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  Complex Sorting Help
>
> In XSLT 2.0 you can create a user-defined function and call it to compute
> your sort key.
>
> In 1.0 the simplest solution is probably a two-pass one: in the first
> pass,
> compute the sort keys and add them as an extra attribute to the Property
> elements; in the second pass, sort on that attribute.
>
> Michael Kay
> http://www.saxonica.com/
>
> > -----Original Message-----
> > From: Crist, Trevor [mailto:tcrist@xxxxxxxxxxxx]
> > Sent: 26 February 2006 00:02
> > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  Complex Sorting Help
> >
> > In the following example, I am trying to return the Property
> > with the cheapest TOTAL rate first.
> > What I WANT to do is something like, this, but of course it
> > doesn't work...
> > Any ideas how to get the desired results?
> >
> > XML:
> > <Properties>
> > 	<Property Name="My Hotel">
> >  		<Room Name="King Room">
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="180.00"/>
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="180.00"/>
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="100.00"/>
> > 		</Room>
> > 		<Room Name="Suite">
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="280.00"/>
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="280.00"/>
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="240.00"/>
> >             </Room>
> > 	</Property>
> > 	<Property Name="Other Hotel">
> >             <Room Name="Queen Room">
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="150.00"/>
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="165.00"/>
> > 			<Day Date="04/15/2006" Quantity="2"
> > Price="165.00"/>
> >             </Room>
> > 	</Property>
> > </Properties>
> >
> >
> >
> > XSL:
> > <xsl:for-each select="Property">
> > <xsl:sort order="ascending" data-type="number"
> > select="Room/sum(Day/@Price)"/>
> >        <br/><br/>
> >        <xsl:value-of select="@Name"/> <br/>
> >
> >        <xsl:for-each select="Room">
> >                    &#160; <xsl:value-of select="@Name"/> :
> > 			<xsl:value-of select="sum(Day/@Price)"/>
> >        </xsl:for-each>
> > </xsl:for-each>
> >
> >
> >
> > DESIRED RESULTS:
> > My Hotel
> >  King Room: 460.00
> >  Suite: 800.00
> >
> > Your Hotel
> >  Queen Room: 480.00

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.