Project

Profile

Help

Bug #6221

closed

Saxon 12.3: Static error in XPath expression supplied to xsl:evaluate: Cannot find a 1-argument function named Q{http://www.w3.org/2005/xpath-functions}transform()

Added by Dimitre Novatchev about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
XSLT conformance
Sprint/Milestone:
-
Start date:
2023-10-11
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

This transformation:

<t>
  let $myMap := function() as map(*)
  {
  let $result := transform(
  map {
  "delivery-format" : "raw",
  "stylesheet-location" : "file:///c:/Marrowsoft/Xselerator25/identity.xsl",
  "source-node": doc("file:///c:/Marrowsoft/Xselerator25/identity.xsl"),
  
  "template-params": map{QName("", "pFilePaths"): "file:///c:/somePath"}
  }
  )
  return $result
  }
  return
  $myMap()
</t>

when applied on this XML document:

<t>
  let $myMap := function() as map(*)
  {
  let $result := transform(
  map {
  "delivery-format" : "raw",
  "stylesheet-location" : "file:///c:/Marrowsoft/Xselerator25/identity.xsl",
  "source-node": doc("file:///c:/Marrowsoft/Xselerator25/identity.xsl"),
  
  "template-params": map{QName("", "pFilePaths"): "file:///c:/somePath"}
  }
  )
  return $result
  }
  return
  $myMap()
</t>

with Saxon 12.3 (Java, EE via Oxygen and also standalone (HE))produces this error:

" Static error in XPath expression supplied to xsl:evaluate: Cannot find a 1-argument function named Q{http://www.w3.org/2005/xpath-functions}transform() ** "

Not tested with Saxon.NET but this will probably be the same there, too.

Error screenshot with 12.3

When the same transformation is applied with Saxon 11.4 no error is raised and the expected result (a map with a single key "output") is produced.

Normal  execution screenshot with 11.4


Files

clipboard-202310111340-aiqgk.png (120 KB) clipboard-202310111340-aiqgk.png Error screenshot with 12.3 Dimitre Novatchev, 2023-10-11 22:40
clipboard-202310111341-ghnsr.png (101 KB) clipboard-202310111341-ghnsr.png Normal execution screenshot with 11.4 Dimitre Novatchev, 2023-10-11 22:41
bugData.xml (389 Bytes) bugData.xml The source XML Dimitre Novatchev, 2023-10-11 22:43
bugIdentity.xsl (478 Bytes) bugIdentity.xsl The transformation Dimitre Novatchev, 2023-10-11 22:43
identity.xsl (309 Bytes) identity.xsl Referred to but probably not used Dimitre Novatchev, 2023-10-11 22:44
Actions #1

Updated by Martin Honnen about 1 year ago

Houston, we have a problem, fn:transform has gone missing for xsl:evaluate.

Simpler test case (run with 12.3 -it):

<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xsl:output method="text" omit-xml-declaration="yes" indent="yes"/>
  
  <xsl:param name="xpath" as="xs:string" expand-text="no"><![CDATA[
  transform(
    map {
      "delivery-format" : "raw",
      "stylesheet-text" : "<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""3.0""><xsl:mode on-no-match=""shallow-copy""/></xsl:stylesheet>",
      "source-node": parse-xml('<root>test</root>')
    }
  )  
  ]]></xsl:param>
  
  <xsl:variable name="vResult" as="map(*)">
    <xsl:evaluate xpath="$xpath"/>
  </xsl:variable>
  
  <xsl:template name="xsl:initial-template">
    <xsl:sequence select=
      "serialize($vResult, map{'method':'adaptive'})"/>
  </xsl:template>
  
</xsl:stylesheet>

gives

Error in expression in xsl:evaluate/@xpath on line 16 column 35 of sheet1.xsl:
  XTDE3160  Static error in XPath expression supplied to xsl:evaluate: Cannot find a
  1-argument function named Q{http://www.w3.org/2005/xpath-functions}transform(). Expression: {
  transform(
    map {
      "delivery-format" : "raw",
      "stylesheet-text" : "<xsl:stylesheet
  xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""3.0""><xsl:mode
  on-no-match=""shallow-copy""/></xsl:stylesheet>",
      "source-node": parse-xml('<root>test</root>')
    }
  )
  }
at template xsl:initial-template on line 19 column 45 of sheet1.xsl:
Static error in XPath expression supplied to xsl:evaluate: Cannot find a 1-argument function named Q{http://www.w3.org/2005/xpath-functions}transform(). Expression: {
  transform(
    map {
      "delivery-format" : "raw",
      "stylesheet-text" : "<xsl:stylesheet xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"" version=""3.0""><xsl:mode on-no-match=""shallow-copy""/></xsl:stylesheet>",
      "source-node": parse-xml('<root>test</root>')
    }
  )
  }
Actions #2

Updated by Martin Honnen about 1 year ago

This seems to be a bug since 12.0; basically, as far as I understand it, both 12 and 11 (tested with 12.3 and 11.6) in e.g. https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/revisions/he_mirror_saxon_12_3/entry/src/main/java/net/sf/saxon/expr/instruct/EvaluateInstr.java#L525 and https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/entry/src/main/java/net/sf/saxon/expr/instruct/EvaluateInstr.java?utf8=%E2%9C%93&rev=he_mirror_saxon_11_6#L356, respectively, do int version = instr.getRetainedStaticContext().getPackageData().getHostLanguageVersion(); but then while 11.6 in https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/entry/src/main/java/net/sf/saxon/expr/instruct/EvaluateInstr.java?utf8=%E2%9C%93&rev=he_mirror_saxon_11_6#L380 does libraryList1.addFunctionLibrary(version == 40 ? XPath40FunctionSet.getInstance() : XPath31FunctionSet.getInstance()); Saxon 12.3 in https://saxonica.plan.io/projects/saxonmirrorhe/repository/he/revisions/he_mirror_saxon_12_3/entry/src/main/java/net/sf/saxon/expr/instruct/EvaluateInstr.java#L549 does libraryList1.addFunctionLibrary(config.getXPathFunctionSet(version)); and that way seems to pull the XPath 3.0 (not XPath 3.1) function library which doesn't have fn:transform.

Actions #3

Updated by Michael Kay about 1 year ago

xsl:evaluate is using the version of XPath that corresponds to the version of XSLT being used, which means that if XSLT 3.0 is used, you get XPath 3.0, which does not recognise the fn:transform() function.

Although XSLT 3.0 only mandates XPath 3.0 support, it permits processors to support XPath 3.1 and Saxon normally does so. The code change here was presumably intended to ensure that if XSLT 4.0 is in use, xsl:evaluate will support XPath 4.0, but the change had this unfortunate consequence.

In fact support for XPath 3.0 as distinct from 3.1 is largely discontinued in Saxon, and there are only a few vestiges left, such as the different function sets in the core function library.

Actions #4

Updated by Dimitre Novatchev about 1 year ago

Michael Kay wrote in #note-3:

xsl:evaluate is using the version of XPath that corresponds to the version of XSLT being used, which means that if XSLT 3.0 is used, you get XPath 3.0, which does not recognise the fn:transform() function.

Although XSLT 3.0 only mandates XPath 3.0 support, it permits processors to support XPath 3.1 and Saxon normally does so. The code change here was presumably intended to ensure that if XSLT 4.0 is in use, xsl:evaluate will support XPath 4.0, but the change had this unfortunate consequence.

In fact support for XPath 3.0 as distinct from 3.1 is largely discontinued in Saxon, and there are only a few vestiges left, such as the different function sets in the core function library.

Then let us immediately publish an official XSLT 3.1 Specification, containing the only sentence: " Same as 3.0 but mandating the support of XPath 3.1 "

Actions #5

Updated by Michael Kay about 1 year ago

Then let us immediately publish an official XSLT 3.1 Specification, containing the only sentence: " Same as 3.0 but mandating the support of XPath 3.1 "

A one-sentence change to the spec that would require a significant amount of effort in the test suite.

Actions #6

Updated by Michael Kay about 1 year ago

The way we set the XPath language level for xsl:evaluate is

env.setXPathLanguageLevel(version == 40 ? 40 : config.getConfigurationProperty(Feature.XPATH_VERSION_FOR_XSLT));

and we should use the same logic for the function library level. The property XPATH_VERSION_FOR_XSLT defaults to 31 but is configurable,

Actions #7

Updated by Michael Kay about 1 year ago

I have been adding to the unit tests in TestXsltCompiler to include testing of the language accepted by xsl:evaluate.

In doing this, I've established that for XPath expressions directly embedded in XSLT 3.0 we always (unconditionally) allow all functions defined in F+O 3.1, regardless of the configuration property XPATH_VERSION_FOR_XSLT (the configuration property only affects the XPath syntax accepted, not the function library). I don't intend to change this, because making functions unavailable that were previously available seems highly unfriendly.

Should the same apply to XPath expressions passed to xsl:evaluate? Well, ideally, xsl:evaluate would have a parameter to say which version of XPath is to be used. There's no particular reason it should be tied to the XSLT version, except as a default. The whole point is that the XPath expressions being evaluated are not actually part of the XSLT stylesheet code. But we're not designing new features here, we're fixing bugs...

I think I will make xsl:evaluate follow the same rules as directly embedded expressions - that is, you get the 3.1 function library unless you explicitly request 4.0.

Actions #8

Updated by Michael Kay about 1 year ago

  • Status changed from New to Resolved
  • Applies to branch trunk added
  • Fix Committed on Branch 12, trunk added
  • Platforms .NET added

Fixed on the 12.x and main branches. New tests (in TestXsltCompiler) also back-ported to the 11.x branch.

Actions #9

Updated by O'Neil Delpratt about 1 year 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