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

Re: Re: Sort By calclulated variable

Subject: Re: Re: Sort By calclulated variable
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 4 Sep 2006 14:23:16 +0100
Re:  Re: Sort By calclulated variable
You need to sort on an expression that depends on the current item being
sorted, not on a variable (which will always have the same value on
every item)

In xslt1 it needs to be done in a single xpath (the same is true in
xslt2 but is not a restriction there as in xslt2 you can call arbitrary
xslt instructions from xpath)

so i'd guess that it is something like

<xsl:sort
select="sum(Price/Amount|$root[current()/Price/Amount]/Price/Amount|//Group[not(current()/Price/Amount)]/Price/Amount)"/>

Although //Group/Price/Amount/text() looks very odd // is a very
expensive operation, if you know where your Group element is, you should
give an explict path to it. Your version (with value-of) would just use
the first Group and silently discard any laterones, my version with
sum() would sum all the Group prices, i have no idea which you need. I
also left of the text() as it's usually a bad idea to have text() in
such an Xpath (it forces the system to do the wrong thing if there are
any comments in that element) In any case it is a constant value, so
perhaps you want
<xsl:variable name="default" select="/a/b/c/Group/Price/Amount)])"/>

...
<xsl:sort select="sum(Price/Amount|$root[current()/Price/Amount]/Price/Amount|$default[not(current()/Price/Amount)])"/>

David

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.