[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Passing sort criteria as a paramter

Subject: Re: Passing sort criteria as a paramter
From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx>
Date: Fri, 25 Jan 2002 10:25:16 +0000
sort criteria
Hi David,

> You seemed to get this msg to the list. Wendell, thanks. I didn't
> think of that. BTW, can I use an xsl:attribute tag for another xsl
> element?

Since Wendell nabbed the other question, I'll answer this one ;)

I take it you're asking whether you can use xsl:attribute to
dynamically create an attribute on an XSLT element. So you're asking
if you can do:

  <xsl:sort>
    <xsl:attribute name="select">
      <xsl:value-of select="$sortby" />
    </xsl:attribute>
  </xsl:sort>

As a way of getting around the fact that $sortby is a string and you
want to interpret it as an XPath expression.

The answer is no, you can't. You can only use xsl:attribute to add
attributes onto result elements (whether created with literal result
elements or with xsl:element).

Of course if the 'xsl:sort' were a literal result element, then it
would be fine. So if you were generating a stylesheet from your
stylesheet, and set up a namespace alias for the XSLT namespace so
that 'oxsl' was the prefix used for the XSLT elements you're
generating, you can do:

  <oxsl:sort>
    <xsl:attribute name="select">
      <xsl:value-of select="$sortby" />
    </xsl:attribute>
  </oxsl:sort>

and it will generate:

  <oxsl:sort select="Amount[../IsCredit = 1]" />

By the way, I suggest that you forward your use case on to
xsl-editors@xxxxxx - hopefully if they receive enough use cases then
they will add an evaluate() function to XSLT 2.0, so that you could
just do:

  <xsl:sort select="evaluate($sortby)" />

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.