Project

Profile

Help

Bug #6094

closed

saxon:eval and saxon:expression no longer available with Saxon 12

Added by Radu Coravu 10 months ago. Updated 5 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Saxon extensions
Sprint/Milestone:
-
Start date:
2023-06-23
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
12, trunk
Fix Committed on Branch:
12, trunk
Fixed in Maintenance Release:
Platforms:
.NET, Java

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?

Actions #1

Updated by Michael Kay 10 months ago

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.

Actions #2

Updated by Radu Coravu 10 months ago

Thanks Michael, and what is an alternative for calling these functions in XQuery?

Actions #3

Updated by Martin Honnen 10 months ago

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> })
Actions #4

Updated by Radu Coravu 10 months ago

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.

Actions #5

Updated by Michael Kay 6 months ago

  • 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.

Actions #6

Updated by Michael Kay 6 months ago

  • Category set to Saxon extensions
  • Assignee set to Michael Kay
Actions #7

Updated by Radu Coravu 6 months ago

Thanks Michael, so in Saxon 12.4 the functions will start working again both in XSLT and XQuery files.

Actions #8

Updated by Michael Kay 6 months ago

Yes, that's right.

Actions #10

Updated by O'Neil Delpratt 5 months ago

  • 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