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

RE: Parametrized xsl:sort

Subject: RE: Parametrized xsl:sort
From: "Américo Albuquerque" <aalbuquerque@xxxxxxxxxxxxxxxx>
Date: Fri, 30 Aug 2002 18:13:21 +0100
xsl sort select name
Hi Neale.

you could try:
	<xsl:call-template name="petTable">
		<xsl:with-param name="selection"
select="pet[@species='dog']"/>
		<xsl:with-param name="sortkey" select="'name'"/> <!--
select a string name instead of attribute -->
		<xsl:with-param name="sortorder" select="'descending'"/>
	</xsl:call-template>

	<xsl:template name="petTable">
		<xsl:param name="selection" select="*"/>
		<xsl:param name="sortkey" select="''"/>
		<xsl:param name="sortorder" select="''"/>
		...
		<xsl:apply-templates select="$selection">
			<xsl:sort select="@*[name()=$sortkey]"
order="descending"/>
		</xsl:apply-templates>
	..>
	</xsl:template>

this is untested but it might work. the select will look for the
attribute named $sortkey and use that in the sort.


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Neale
Morison
Sent: Friday, August 30, 2002 5:04 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Parametrized xsl:sort




> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]On Behalf Of Peter Davis
> Sent: Friday, 30 August 2002 12:57 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: Re:  Parametrized xsl:sort
>
>
> On Thursday 29 August 2002 19:15, Neale Morison wrote:
> > To be specific, I want the result of:
> >         <xsl:sort select="$sortkey" order="descending"/>
>
> Since a normal variable doesn't change, the sort will have no effect
> (but I'm sure you already figured this out).
>
> > with parameter sortkey:
> >         <xsl:with-param name="sortkey" select="@name"/>
>
> If you pass select="@name", it will evaluate "@name" in the context of

> the with-param, not in the sort.  So you probably want to change this
> to:
>
> <xsl:with-param name="sortkey" select="'@name'"/>
>
> which will pass the string '@name' to be evaluated later.
>
> > to be equivalent to:
> >         <xsl:sort select="@name" order="descending"/>
>
> To evaluate the string, you need to use some kind of extension
> function.  Look in the documentation of whatever processor you use; it

> will probably look
> like:
>
> <xsl:sort order="descending" select="xxx:evaluate($sortkey)"/>
>
> The 'xxx' will be associated with an extension namespace specific to
> your processor.  The evaluate() function will take the string $sortkey

> and evaluate it as an XPath expression.
>
> --
> Peter Davis
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Thanks. I thought I might be able to do it without an eval, but the eval
method does work. Regards, Neale

 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.