[xsl] Changing sort order via a parameter

Subject: [xsl] Changing sort order via a parameter
From: Danny Vint <dvint@xxxxxxxxxxxxxx>
Date: Wed, 04 Jun 2003 16:05:37 -0700
I have a situation where I need to change from a text ordering to number order depending upon a parameter. I know this value at the start of the process, so I don't have to determine that.

I've tried the following:

<xsl:for-each test="xxx">
	<xsl:sort select="zzz">
		<xsl:attribute name="data-type">
			<xsl:choose>
				<xsl:when test="$A='Life'">number</xsl:when>
				<xsl:when test="$A='P_C'">text</xsl:when>
			</xsl:choose>
		</xsl:attribute>
	</xsl:sort>
</xsl:for-each>

Doesn't work because I'm creating an attribute on the stylesheet element.

<xsl:for-each test="xxx">
	<xsl:sort select="zzz">
		<xsl:attribute name="data-type">
	<xsl:choose>
		<xsl:when test="$A='Life'">
			<xsl:sort select="zzz" data-type="number"?>
		</xsl:when>
		<xsl:when test="$A='P_C'">
			<xsl:sort select="zzz" data-type="text"?>
		</xsl:when>
	</xsl:choose>
</xsl:for-each>

This doesn't work because xsl:sort is not a child of xsl:template or xsl:for-each. Is there some other method I have missed? I would like to avoid duplicating the code just to control the sort order, and this means also putting the code into a named template.

..dan
---------------------------------------------------------------------------
Danny Vint
http://www.dvint.com






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


Current Thread