Bug #4723


XSLT 3 using function-lookup gives TypeError: h is not a function

Added by Martin Honnen almost 4 years ago. Updated over 3 years ago.

XSLT Conformance
Start date:
Due date:
% Done:


Estimated time:
Applies to JS Branch:
Fix Committed on JS Branch:
Fixed in JS Release:
SEF Generated with:
Contact person:
Additional contact persons:


I have tried to run an XSLT 3 example using function-lookup that works fine with Saxon Java 10 HE through Saxon-JS 2 under Node with xslt3 but there it gives an error "TypeError: h is not a function".

Reduced test case is:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl=""
    <xsl:mode on-no-match="shallow-copy"/>
    <xsl:template match="example">
            function-lookup(xs:QName(function), count(arguments/arg))
            apply(array { arguments/arg })
    <xsl:template match="/" name="xsl:initial-template">
        <xsl:comment xmlns:saxon="">Run with {system-property('xsl:product-name')} {system-property('xsl:product-version')} {system-property('Q{}platform')}</xsl:comment>

input sample:


Result with xslt3:

<?xml version="1.0" encoding="UTF-8"?><root>
    Transformation failure: TypeError: h is not a function
Transformation failed: TypeError: h is not a function

Expected result is the one I get with Saxon Java:

<?xml version="1.0" encoding="UTF-8"?><root>
Actions #1

Updated by Michael Kay almost 4 years ago

Added XSLT3 test case function-lookup-008; confirmed the failure.

With the debug version of the code we get:

TypeError: $untypedConversion$$ is not a function
    at /Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:11919:41
    at (<anonymous>)
    at Object.$coerce$$ [as coerce] (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:11918:41)
    at $$CoreFunction$$$.$$XdmFunction$$$$convertArgs$ [as convertArgs] (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:3820:77)
    at $$CoreFunction$$$$evaluate$ [as evaluate] (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:3868:48)
    at applyFn (/Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:9836:24)
    at /Users/mike/GitHub/saxon-js-enterprise/build/temp/js/build/SaxonJS2N.debug.js:12701:14

This corresponds to line 3013 in Expr.js; variable untypedConversion is undefined, because RT (required type) is anyAtomicType, which does not have a cast method. Effectively we're invoking the function conversion rules with a supplied value that's the untypedAtomic value "a", and a required type that's anyAtomicType (being the declared argument type of fn:concat#3), and I think the correct action in that situation is to perform no conversion.

Actions #2

Updated by Debbie Lockett almost 4 years ago

  • Assignee set to Debbie Lockett
Actions #3

Updated by Michael Kay almost 4 years ago

  • Status changed from New to In Progress
  • Assignee changed from Debbie Lockett to Michael Kay

Changed the code so if reqCode="A" (meaning xs:anyAtomicType) we do no conversion.

The test no longer crashes, but it does not produce the expected results. I'm having trouble understanding the failure; when the test is run from the command line (rather than the test driver) it seems to produce the correct output.

Actions #4

Updated by Michael Kay over 3 years ago

  • Status changed from In Progress to Resolved

The test appears to be working both when run directly from the command line, and when run from the test driver. Marking as resolved.

Actions #5

Updated by Community Admin over 3 years ago

  • Applies to JS Branch 2 added
  • Applies to JS Branch deleted (2.0)
Actions #6

Updated by Debbie Lockett over 3 years ago

  • Fix Committed on JS Branch 2 added
Actions #7

Updated by Debbie Lockett over 3 years ago

  • Status changed from Resolved to Closed
  • % Done changed from 0 to 100
  • Fixed in JS Release set to Saxon-JS 2.1

Bug fix applied in the Saxon-JS 2.1 maintenance release.

Please register to edit this issue

Also available in: Atom PDF Tracking page