RE: Evaluation function

There is no standard function to do this.
 
A number of XSLT processors (Saxon was the first) have provided an
evaluate() function to fill this gap - there is a semi-standardized
specification at www.exslt.org. Unfortunately Saxon's version,
saxon:evaluate() is not currently available via the XQuery interface, only
via XSLT. I don't think there's a good technical reason for this
restriction, it's mainly a question of testing.
 
One or two of us did push quite hard for a standard evaluate() function, but
the WG decided against. The main arguments, if I recall, were (a) that it
broke type safety, (b) that some processors use a compilation architecture
in which the parser isn't available at run-time, and (c) that it's not
obvious how much of the static/dynamic context should be available to the
evaluated expression.
 
(At least you understand what it is that you're asking for! A lot of XSLT
users have stumbled into this without knowing what they are doing, they try
to write things like a[$x] where $x is the string "@foo='bar'" I think the
problem is that the use of $ to introduce variables is associated in some
people's minds with macro languages).
 
Michael Kay

  _____  

From: www-ql-request@w3.org [mailto:www-ql-request@w3.org] On Behalf Of
Stéphane Mbaye
Sent: 22 July 2004 23:48
To: XQuery
Subject: Evaluation function


Dear all,
 
how to evaluate a string as an Expr or ExprSignle expression from the body
of a query script ? As en example is may be useful in the following script:
 
declare variable $query as xs:string external;
fn:evaluate($query)
 
Thank you in advance.
Stephane Mbaye
 
GAEL Consultant

Received on Thursday, 22 July 2004 19:09:25 UTC