|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: Evaluating parameter in <xsl:when> vs evaluating p
Hi Roelf,
> The solution turned out to be:
> ..
> <xsl:when test="$sortParameter='name'" >
>
> <xsl:for-each select="query">
> <xsl:sort select="xalan:evaluate($sortParameter)"
> order="ascending"/>
Within the xsl:when, you *know* that the $sortParameter has the value
'name', so there's no point evaluating it dynamically (which is costly
in terms of processing) -- you can just fix the path used in the
xsl:sort instead:
<xsl:when test="$sortParameter = 'name'">
<xsl:for-each select="query">
<xsl:sort select="name" />
...
</xsl:for-each>
</xsl:when>
> Why is it that in the <when> & <copy> tags I can call it simply but
> in the sort tag it needs the xalan:evaluate() ?
In the XPath expressions on the xsl:when and xsl:copy-of elements,
you're wanting to treat $sortParameter as a string and either test or
output the value of that string.
In the XPath expression on the xsl:sort, you're wanting to evaluate
the string "name" as the XPath expression "name", which selects the
value of the name element child of the context (query) element. If you
selected just the value of the $sortParameter, as in:
<xsl:sort select="$sortParameter" />
then it would be equivalent to:
<xsl:sort select="'name'" />
which would mean that you'd be sorting each query by the string
'name' -- the string 'name' is always the string 'name', so they'd
each get the same value to be sorted by, and they would sort in their
normal order.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








