Hi List!
I have some trouble with "xsl:sort" in XSLT 1.0. FYI, it must run on a
client IE, FF, Op etc, using Msxml2.XSLTemplate.5.0 on MS IE and
XSLTProcessor() on others. I am well aware of the shortcomings of this
approach. Most of the time, sticking strictly to XSLT 1.0 specs gets me
a long way.
The logical thing I am trying to achieve is the following (order by
cell[1] if $name variable is not equal to 'generic'):
<xsl:apply-templates select="twz:rows/twz:row" >
<xsl:if test="$name != 'generic'">
<xsl:sort select="twz:cell[1]" order="ascending" />
</xsl:if>
</xsl:apply-templates>
But this is illegal syntax, as xsl:sort cannot be a child of xsl:if. It
doesn't trigger an error either, by the way. I came up with this brute
force solution:
<xsl:if test="$name = 'generic'">
<xsl:apply-templates select="twz:rows/twz:row" />
</xsl:if>
<xsl:if test="$name != 'generic'">
<xsl:apply-templates select="twz:rows/twz:row" >
<xsl:sort select="twz:cell[1]" order="ascending" />
</xsl:apply-templates>
</xsl:if>
But actually I hoped to be able to do something like this eventually:
<xsl:apply-templates select="twz:rows/twz:row" >
<xsl:sort select="($name = 'generic' and position()) or
twz:cell[1]" order="ascending" />
</xsl:apply-templates>
Is my approach the "xslt way" of doing things, or is there a different
way of doing this? Is there a pattern available about this? In addition,
I would like to ask how to extend the solution above to order the list
in such a way that all is ordered except items that have the value
"None" or "All". These should end up on the bottom of the list.
Any help or pointers would be appreciated. I tried Michael Kays books,
but these emphasize on XSLT 2.0 and I couldn't find how to do this
better than above.
Cheers,
Abel Braaksma
Nuntia B.V.
www.nuntia.nl (online July 17)
--~------------------------------------------------------------------
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>
--~--