Project

Profile

Help

saxon:evaluate support for "dynamic scoping"

Added by Anonymous about 18 years ago

Legacy ID: #3697979 Legacy Poster: Craeg Strong, Ariel Partners LLC (arielpartners)

Hello: We have a large website based on XALAN/Java and STXX (a Struts plugin that works like a poor man's Apache Cocoon). We would like to migrate to Saxon for enhanced performance and other reasons. However, we have lots of situations where we are using exslt evaluate() and passing it strings with embedded variables, like: "concat($data/lastName, ', ', $data/firstName)" For Xalan, the $data variable is evaluated in the current context which essentially simulates dynamic scoping. I believe, however, that saxon does not do this extra step, resulting in $data evaluating to empty string. Can anyone shed light on the whys and wherefores of Saxon's current behavior, and any possible workarounds? Thanks! --Craeg


Replies (2)

RE: saxon:evaluate support for "dynamic scopi - Added by Anonymous about 18 years ago

Legacy ID: #3698043 Legacy Poster: Michael Kay (mhkay)

The workaround for this is that instead of writing xalan:evaluate("$x + $y") you write saxon:evaluate("$p1 + $p2", $x, $y) Within the expression, $p1 always refers to the value supplied in the second argument, $p2 to the value in the third argument, and so on. The reason for this design is that the Saxon optimizer needs to know how and whether stylesheet variables are referenced. For example, if a variable is only used once, then the value might not be stored in memory, instead Saxon effectively replaces the variable reference with the expression to which it is bound. This means that run-time references to variables won't necessarily work, because the variable might not really exist. In the above example Saxon can see at compile time that $x and $y are used by the saxon:evaluate expression, so it can make sure that the values are available.

RE: saxon:evaluate support for "dynamic scopi - Added by Anonymous about 18 years ago

Legacy ID: #3698140 Legacy Poster: Craeg Strong, Ariel Partners LLC (arielpartners)

Thanks a million! woo-hoo saxon here we come :-)

    (1-2/2)

    Please register to reply