[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Sorting on different elements...


Subject: RE: [xsl] Sorting on different elements...
From: "Chris Ward" <cward@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 22 Jan 2004 10:18:17 -0000

Many thanks.

Best regards
Chris

> -----Original Message-----
> From: Jarno.Elovirta@xxxxxxxxx [mailto:Jarno.Elovirta@xxxxxxxxx] 
> Sent: Thursday, January 22, 2004 10:15 AM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Sorting on different elements...
> 
> 
> Hi,
> 
> > Sorry if this has been asked before - or is a daft question.
> 
> It's a FAQ.
>  
> > Is it possible to parameterise an <xsl:sort> ?
> > 
> > Example.
> > 
> > 	<root>
> > 		<data>
> > 			<firstname value="Fred"/>
> > 			<lastname value="Smith"/>
> > 		</data>
> > 		<data>
> > 			<firstname value="Tom"/>
> > 			<lastname value="Jones"/>
> > 		</data>
> > 		<data>
> > 			<firstname value="Myles"/>
> > 			<lastname value="Ward"/>
> > 		</data>
> > 		...
> > 	</root>
> > 
> > Sometimes I want to sort <data> on "firstname/@value" sometimes on 
> > "lastname/@value" based on a user parameter of some kind.
> 
> Use a sort rule
> 
>   <xsl:sort select="*[name() = $x]/@value"/>
> 
> where $x is bound to either "firstname" or "lastname".
> 
> Cheers,
> 
> Jarno - Covenant: Tension
> 
>  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