You are doing exactly what the error message says: you are using xsl:sort in
a place where it may not be used. Within xsl:for-each, it must be the first
child of the xsl:for-each.
Try using two sort keys:
<xsl:for-each select="codes/value[code_type = $code_type]">
<xsl:sort select="*[name()=$select_sort_field]" />
<xsl:sort select="code" />
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Hardy Merrill [mailto:HMerrill(_at_)dhcr(_dot_)state(_dot_)ny(_dot_)us]
Sent: 10 December 2004 13:55
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: [xsl] xsl:sort not working within xsl:choose
MSXML4
I'm passing a script parameter into the xsl style sheet that tells me
what the sort field should be:
<xsl:param name="select_sort_field"/>
and then, within my for-each loop, I have the code to decide what to
sort by:
<xsl:for-each select="codes/value[code_type = $code_type]">
<xsl:choose>
<xsl:when test="$select_sort_field">
<xsl:sort select="*[name()=$select_sort_field]" />
</xsl:when>
<xsl:otherwise>
<xsl:sort select="code" />
</xsl:otherwise>
</xsl:choose>
<!-- <xsl:sort select="code" /> -->
<!-- <xsl:sort select="*[name()=$select_sort_field]" /> -->
-----------------------------------
but that's not working - I keep getting this error:
msxml4.dll error '80004005'
Keyword xsl:sort may not be used here.
------------------------------------
What am I doing wrong? The thing is, if I take out the entire choose,
and just use
<xsl:sort select="code" />
or
<xsl:sort select="*[name()=$select_sort_field]" />
it seems to work. The thing is, I wanted to make it bullet proof in
case the script invoking this style sheet doesn't pass in the
$select_sort_field parameter - if not passed in, I want it to sort by
"code".
TIA.
Hardy Merrill.
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail:
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--