Project

Profile

Help

bug? saxon:evaluate,eval(expression()): scope

Added by Anonymous over 16 years ago

Legacy ID: #4928499 Legacy Poster: Chapman Flack (jcflack)

http://saxonica.com/documentation/extensions/functions/evaluate.html says: " The function saxon:evaluate(string) is shorthand for saxon:eval(saxon:expression(string)). " But it's not. Consider: declare function local:zoich() { 'zoiched.' }; saxon:evaluate('local:zoich()') which produces the string 'zoiched', and declare function local:zoich() { 'zoiched.' }; saxon:eval(saxon:expression('local:zoich()')) which produces: Error XPST0017: XPath syntax error at char 13 in {local:zoich()}: Cannot find a matching 0-argument function named {http://www.w3.org/2005/xquery-local-functions}zoich() Static error(s) in query It seems that imported and user-declared functions are in scope for evaluate(), and not in scope for expression(). What evaluate() says should be in scope: " The static context for the expression includes all the in-scope namespaces, types, and functions from the calling stylesheet or query. It does not include any variables from the calling environment. " What expression() says should be in scope: " It may contain calls on Java extension functions, including Saxon and EXSLT-defined functions (other than those which are restricted to use within stylesheets, for example the saxon:evaluate() function itself). But it does not allow access to stylesheet variables, stylesheet functions, or functions defined in the XSLT specification such as key() or format-number(). " Why the difference? Is there a technical obstacle to making eval(expression()) genuinely equivalent to evaluate()? Chapman Flack


Replies (2)

RE: bug? saxon:evaluate,eval(expression()) - Added by Anonymous over 16 years ago

Legacy ID: #4928554 Legacy Poster: Chapman Flack (jcflack)

It may have to do with preEvaluate(). If I replace saxon:eval(saxon:expression('local:zoich()')) with let $e := [some gnarly expression returning 'local:zoich()'] return saxon:eval(saxon:expression($e)) then it works. The trick seems to be to make $e something gnarly enough that it's not been reduced to a string literal by the time preEvaluate() sees it, and then it gets left well enough alone. Ok, that gives me a workaround that seems usable both in 8 and 9. -Chap

RE: bug? saxon:evaluate,eval(expression()): s - Added by Anonymous over 16 years ago

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

Thanks, I have logged this bug at https://sourceforge.net/tracker/index.php?func=detail&aid=1952138&group_id=29872&atid=397617 and a fix is in Subversion. I will also fix the documentation. Michael Kay Saxonica

    (1-2/2)

    Please register to reply