|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: xsl:variable and key
At 2004-06-10 19:34 -0700, Sameer N wrote:
I want to assign a node-set returned by key() to a variable. Sure. But now I have a condition and I have to use <xsl:choose>. Actually, for your example you are not obliged to use <xsl:choose> and there is a trick to getting what you want.
In XSLT 1.0 I would do the following: <xsl:variable name="foo" select="key('XXX',YYY)[SOME-TEST] |
ancestor::*[1][not(SOME-TEST)]"/>Essentially I'm assigning the union of two node set expressions where only one of them will be non-empty because of the application of the predicate to each operand and one of the predicates will be true and the other will be false. Better still you could distill out the test as: <xsl:variable name="test" select="SOME-TEST"/>
<xsl:variable name="foo" select="key('XXX',YYY)[$test] |
ancestor::*[1][not($test)]"/>Not elegant, but it will do what you asked for ... are you sure that is what you want and there isn't a better way? I hope this helps. .................. Ken
|
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








