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

RE: Using variables in xsl:sort select attribute

Subject: RE: Using variables in xsl:sort select attribute
From: Mike McGraw <mmcgraw@xxxxxxx>
Date: Thu, 24 May 2001 12:51:12 -0400
xsl sort select variable
Thanks! That worked great. I still don't understand why I couldn't use a
variable as the argument of the select attribute though. Anyway, much thanks

Mike 



> -----Original Message-----
> From: Adam Turoff [mailto:ziggy@xxxxxxxxx]
> Sent: Thursday, May 24, 2001 12:36 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Using variables in xsl:sort select attribute
> 
> 
> On Thu, May 24, 2001 at 12:01:50PM -0400, Mike McGraw wrote:
> > <xsl:template match="customerList">
> > <xsl:variable name="sortby" select="@sortby">
> > 
> > <xsl:for-each select="person">
> > <xsl:sort select="$sortby"/>
> > 	<tr>
> > 	<td><xsl:value-of select="name" /></td>
> > 	<td><xsl:value-of select="age" /></td>
> > 	</tr>
> > </xsl:for-each>
> > 
> > </xsl:template>
> > 
> > However, this doesn't work. The parser ignores the sort 
> instruction. Am I
> > permitted to use a variable as the argument for the select 
> attribute of the
> > sort?
> 
> It looks like select="$sortby" is a constant expression, so 
> the results
> are in their original order.
> 
> Try this instead (yes, it's ugly, but it sorts):
> 
> 	<xsl:for-each select="person/*[name() = $sortby]">
> 	<xsl:sort select="."/>
> 		<tr>
> 		<td><xsl:value-of select="../name" /></td>
> 		<td><xsl:value-of select="../age" /></td>
> 		</tr>
> 	</xsl:for-each>
> 
> Z.
> 
> 
>  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.