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

Re: sort

Subject: Re: sort
From: Frederic Leclercq <frederic@xxxxxxxxxxxxx>
Date: Sat, 02 Feb 2002 02:27:12 +0100
frederic leclercq
Thanks, but maybe my question was not that clear.
I display a table and the clients can click the headers to sort the table. (html)


But not every <td></td> is at the same level in the xml-string.... so some clients would like to sort (at xml level) <root><person></person></root>
and other clients may want to sort on <root><person><extra><extra></person></root>


Hope you understand me ;-)

Thx in advance,
Fred.

Jonathan Perret wrote:

If the depth of the sorting-element can be bounded to e.g. 3 :
First, parse your sort specification (e.g., 'person.superlogin.login') into
several variables - in this case it would give :
$sortdepth=3
$sortering1='person'
$sortering2='superlogin'
$sortering3='login'
For a simpler sort, e.g. on 'person' it would give :
$sortdepth=1
$sortering1='person'
$sortering2=''
$sortering3=''
This is easy to do with substring-before() and substring-after(), so I'll
leave it as an exercise :-)

Then you can use the following :

<xsl:apply-templates>
  <xsl:sort select="*[name()=$sortering1 and $sortdepth=1]"
order="{$direction}"/>
  <xsl:sort select="*[name()=$sortering1 and
$sortdepth=2]/*[name()=$sortering2]" order="{$direction}"/>
  <xsl:sort select="*[name()=$sortering1 and
$sortdepth=3]/*[name()=$sortering2]/*[name()=$sortering3]"
order="{$direction}"/>
</xsl:apply-templates>

Hope this helps.
--Jonathan

----- Original Message -----
From: "Frederic Leclercq" <frederic@xxxxxxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Saturday, February 02, 2002 1:24 AM
Subject:  sort

that's one "record" - i have 100's of them in the XML string.

Following works perfect if i would like to sort on one of the first level

tags...

<xsl:apply-templates>
 <xsl:sort select="*[name()=$sortering]" order="{$direction}"/>
</xsl:apply-templates>

But now i would like to sort the xmlstring on

"root.person.supelogin.login"

Anybody could help me out ?

Thx,
Fred.




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list






XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.