Bug #6094
closed
saxon:eval and saxon:expression no longer available with Saxon 12
Category:
Saxon extensions
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Description
I have an older XSLT containing:
<xsl:variable name="context" select="saxon:eval(saxon:expression($contextElementXPathExpression, ./*))"/>
but Saxon 12.2 no longer seems to recognize them:
Cannot find a 2-argument function named Q{http://saxon.sf.net/}expression() at line 18 and column 114
Are there some similar functions which could be used? Or some settings to use when creating the transformer?
We dropped these functions because for many years the standard xsl:evaluate
instruction has been available, which does the same job in a much better way.
Thanks Michael, and what is an alternative for calling these functions in XQuery?
Using fn:tansform
calling a public XSLT function doing the xsl:evaluate
is an option:
declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";
declare option output:method 'xml';
declare option output:indent 'yes';
declare function local:eval($expression as xs:string, $context-item as item()?) as item()* {
transform(
map {
'stylesheet-node' : <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="3.0"
xmlns:mf="http://example.com/mf"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="#all">
<xsl:function name="mf:eval" as="item()*" visibility="public">
<xsl:param name="expression" as="xs:string"/>
<xsl:param name="context-item" as="item()?"/>
<xsl:evaluate xpath="$expression" context-item="$context-item"/>
</xsl:function>
</xsl:stylesheet>,
'initial-function' : QName('http://example.com/mf', 'eval'),
'function-params': [$expression, $context-item],
'delivery-format': 'raw'
}
)?output
};
local:eval('sort(//item)', document { <root><item>b</item><item>c</item><item>a</item></root> })
Thanks Martin, the proposed xquery function seems to work just fine :)
For Michael, one remark about the use of saxon:evaluate inside XQuery with Saxon 12, it seems that the error that the function no longer exists is reported at runtime, not at compile time. For XSLT for example the error is reported directly at compile time and Oxygen presents the error when validating the XSLT instead of needing to transform the content it.
- Tracker changed from Support to Bug
- Status changed from New to Resolved
- Priority changed from Low to Normal
- Applies to branch 12, trunk added
- Fix Committed on Branch 12, trunk added
- Platforms .NET, Java added
Since there is no other equivalent for XQuery users, I have reinstated these extension functions for 12.4.
- Category set to Saxon extensions
- Assignee set to Michael Kay
Thanks Michael, so in Saxon 12.4 the functions will start working again both in XSLT and XQuery files.
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in Maintenance Release 12.4 added
Bug fix applied in the Saxon 12.4 maintenance release
Please register to edit this issue
Also available in: Atom
PDF