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

Re: [xls] run-time variable name generation (e.g. "dou

Subject: Re: [xls] run-time variable name generation (e.g. "double de-referencing" {$($name)} )
From: Lars Huttar <lars_huttar@xxxxxxx>
Date: Mon, 11 May 2009 15:02:24 -0500
Re:  [xls] run-time variable name generation (e.g. "dou
On 5/10/2009 6:00 PM, Michael Kay wrote:
> No, you can't do this.
> (I can't think of any language where you can, except
> some languages where variables are nothing more than macros, e.g. some OS
> script languages).

(At the risk of going off-topic... Can't you do this with 'eval', e.g.
in Lisp or Perl?)

Regarding XSLT, wouldn't the 'evaluate' extension function EXSLT work?

The spec http://www.exslt.org/dyn/functions/evaluate/dyn.evaluate.html
says you can do just what the OP asked, it seems to me:

>  The dyn:evaluate function evaluates a string as an XPath expression and returns the resulting value, which might be a boolean, number, string, node set, result tree fragment or external object. The sole argument is the string to be evaluated.
> The string is always evaluated exactly as if it had been literally included in place of the call to the dyn:evaluate function. For example:
> <xsl:value-of select="dyn:evaluate('my:extension(. * $variable)')" />
> Creates a text node with exactly the same value as:
> <xsl:value-of select="my:extension(. * $variable)" />

Of course you lose some portability, but...

And now I see that Saxon supports this too:
> The supplied string must contain an XPath expression. The result of the function is the result of evaluating the XPath expression. This is useful where an expression needs to be constructed at run-time or passed to the stylesheet as a parameter, for example where the sort key is determined dynamically.
> The function saxon:evaluate(string) is shorthand for saxon:eval(saxon:expression(string)). For the rules governing what may and may not appear in the expression, see saxon:expression. The expression may contain references to variables $p1, $p2, etc

So I'm really confused why Michael Kay would be saying that this isn't
possible in XSLT. Maybe he just means standard, portable XSLT?


Current Thread


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.
First Name
Last Name
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.