Project

Profile

Help

Is there any way to get reflexive extension functions to work in the commercial editions of SaxonC 12?

Added by Martin Honnen 29 days ago

I tried to use a stylesheet with a reflexive extension function that runs fine with Saxon Java 12.4 EE through SaxonC EE 12.4.2's transform command line but it doesn't find the function.

Is there any way to get this working? Or would any class needed for a reflexive extension require registration for reflection when building SaxonC with GraalVM/nativeimage?

Example stylesheet:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  version="3.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:uuid="java:java.util.UUID"
  exclude-result-prefixes="#all"
  expand-text="yes">

  <xsl:template match="/" name="xsl:initial-template">
    <random-uuid>{uuid:randomUUID()}</random-uuid>
    <xsl:comment>Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{http://saxon.sf.net/}platform')}</xsl:comment>
  </xsl:template>
  
</xsl:stylesheet>

Example output with Saxon Java EE: -it -xsl:

<?xml version="1.0" encoding="UTF-8"?><random-uuid>ae9649aa-3462-4b1e-8fcf-1f10e4e6cf7f</random-uuid><!--Run with SAXON EE 12.4 -->

Output with SaxonC EE transform.exe:

Error at  on line 10 column 18 of uuid-reflexive-test1.xsl:
  XPST0017  Cannot find a 0-argument function named Q{java:java.util.UUID}randomUUID(). No
  method or field matching randomUUID with 0 parameters found in class java.util.UUID. For
  diagnostics on calls to Java methods, use the -TJ command line option or set the
  Configuration property FeatureKeys.TRACE_EXTERNAL_FUNCTIONS
Errors were reported during stylesheet compilation

with -TJ:

Looking for function Q{java:java.util.UUID}randomUUID#0
Trying net.sf.saxon.functions.registry.XSLT30FunctionSet
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Trying net.sf.saxon.functions.FunctionLibraryList
Looking for function Q{java:java.util.UUID}randomUUID#0
Trying com.saxonica.ee.extfn.VendorFunctionSetEE
Trying net.sf.saxon.functions.MathFunctionSet
Trying net.sf.saxon.ma.map.MapFunctionSet
Trying net.sf.saxon.ma.arrays.ArrayFunctionSet
Trying com.saxonica.functions.extfn.EXPathBinaryFunctionSet
Trying net.sf.saxon.functions.registry.ExsltCommonFunctionSet
Trying com.saxonica.functions.extfn.EXPathFileFunctionSet
Trying net.sf.saxon.functions.registry.OnDemandFunctionSet
Function Q{java:java.util.UUID}randomUUID not found!
Trying net.sf.saxon.functions.registry.ConstructorFunctionLibrary
Trying net.sf.saxon.query.XQueryFunctionLibrary
Trying net.sf.saxon.functions.IntegratedFunctionLibrary
Trying com.saxonica.config.JavaExtensionLibrary
Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 0
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 0 parameters found in class java.util.UUID
Trying net.sf.saxon.style.XSLOriginalLibrary
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Function Q{java:java.util.UUID}randomUUID not found!
Looking for function Q{java:java.util.UUID}randomUUID#0
Trying net.sf.saxon.functions.registry.XSLT30FunctionSet
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Trying net.sf.saxon.functions.FunctionLibraryList
Looking for function Q{java:java.util.UUID}randomUUID#0
Trying com.saxonica.ee.extfn.VendorFunctionSetEE
Trying net.sf.saxon.functions.MathFunctionSet
Trying net.sf.saxon.ma.map.MapFunctionSet
Trying net.sf.saxon.ma.arrays.ArrayFunctionSet
Trying com.saxonica.functions.extfn.EXPathBinaryFunctionSet
Trying net.sf.saxon.functions.registry.ExsltCommonFunctionSet
Trying com.saxonica.functions.extfn.EXPathFileFunctionSet
Trying net.sf.saxon.functions.registry.OnDemandFunctionSet
Function Q{java:java.util.UUID}randomUUID not found!
Trying net.sf.saxon.functions.registry.ConstructorFunctionLibrary
Trying net.sf.saxon.query.XQueryFunctionLibrary
Trying net.sf.saxon.functions.IntegratedFunctionLibrary
Trying com.saxonica.config.JavaExtensionLibrary
Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 0
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 0 parameters found in class java.util.UUID
Trying net.sf.saxon.style.XSLOriginalLibrary
Trying net.sf.saxon.style.StylesheetFunctionLibrary
Function Q{java:java.util.UUID}randomUUID not found!
Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 1
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 1 parameter found in class java.util.UUID
Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 2
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 2 parameters found in class java.util.UUID
Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 3
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 3 parameters found in class java.util.UUID
Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 4
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 4 parameters found in class java.util.UUID
Error at  on line 10 column 18 of uuid-reflexive-test1.xsl:
  XPST0017  Cannot find a 0-argument function named Q{java:java.util.UUID}randomUUID(). No
  method or field matching randomUUID with 0 parameters found in class java.util.UUID. For
  diagnostics on calls to Java methods, use the -TJ command line option or set the
  Configuration property FeatureKeys.TRACE_EXTERNAL_FUNCTIONS
Looking for function Q{http://www.w3.org/2005/xpath-functions}system-property#1
Trying net.sf.saxon.functions.registry.XSLT30FunctionSet
Looking for function Q{http://www.w3.org/2005/xpath-functions}system-property#1
Trying net.sf.saxon.functions.registry.XSLT30FunctionSet
Looking for function Q{http://www.w3.org/2005/xpath-functions}system-property#1
Trying net.sf.saxon.functions.registry.XSLT30FunctionSet
Errors were reported during stylesheet compilation

So it looks into java.util.UUID but doesn't find the function:

Loading java.util.UUID
Looking for method randomUUID in namespace java:java.util.UUID
Number of actual arguments = 0
Looking in Java class class java.util.UUID
Trying method wait: name does not match
Trying method wait: name does not match
Trying method wait: name does not match
Trying method getClass: name does not match
Trying method notify: name does not match
Trying method notifyAll: name does not match
No method or field matching randomUUID with 0 parameters found in class java.util.UUID

Replies (1)

RE: Is there any way to get reflexive extension functions to work in the commercial editions of SaxonC 12? - Added by Michael Kay 29 days ago

No, I don't think this can be made to work.

Dynamic loading under GraalVM basically isn't possible except under very restricted circumstances.

See https://www.graalvm.org/22.1/reference-manual/native-image/Limitations/

    (1-1/1)

    Please register to reply