[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

Subject: Re: Evaluating parameter in <xsl:when> vs evaluating parameter in <xsl:sort>
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Thu, 25 Jul 2002 10:01:18 +0100
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


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.