This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Passing sort criteria as a paramter
- From: Jeni Tennison <jeni at jenitennison dot com>
- To: "David B. Bitton" <david at codenoevil dot com>
- Cc: xsl-list at lists dot mulberrytech dot com
- Date: Fri, 25 Jan 2002 10:25:16 +0000
- Subject: Re: [xsl] Passing sort criteria as a paramter
- Organization: Jeni Tennison Consulting Ltd
- References: <CC8ECFB81EE5D511AE7500065B199AB30FF5BE@smtp.nyc.banklink.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
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@w3.org - 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