[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Sort on multiple elements
Subject: Re: Sort on multiple elements
From: "J.Pietschmann" <j3322ptm@xxxxxxxx>
Date: Fri, 23 Aug 2002 23:47:13 +0200
|
Jitu wrote:
i can use multiple xsl:sort statements, to sort on many elements.
But my problem is i do not know in advance, how many levels of sorting
is required.
...
I may want to sort
by lastname
OR
by lastname,firstname (sort first by lastname and within it sort by
firstname)
OR
by salary, age, lastname (sort by salary and within it sort by age and
within that sort by lastname)
This fact i do not know in advance therefore i cannot hardcode it into
my xsl. In other words i cannot write a fixed number of xsl:sort
statements.
Note that you have to pull tricks to sort for
a dynamical element name. As for the levels,
code for the maximum level and use a non-existant
field for the unused sort levels, for example
<xsl:param name="level1" select="'lastname'"/>
<xsl:param name="level2" select="'firstname'"/>
<xsl:param name="level3" select="'*'"/> <!-- invalid for any element name -->
...
<xsl:for-each select="employee">
<xsl:sort select="*[name()=$level1]"/>
<xsl:sort select="*[name()=$level2]"/>
<xsl:sort select="*[name()=$level3]"/>
...
HTH
J.Pietschmann
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|