Project

Profile

Help

Bug #4723

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

Added by Martin Honnen 21 days ago. Updated 7 days ago.

Status:
In Progress
Priority:
Normal
Assignee:
Category:
XSLT Conformance
Sprint/Milestone:
-
Start date:
2020-09-04
Due date:
% Done:

0%

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

Description

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="http://www.w3.org/1999/XSL/Transform"
    version="3.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:fn="http://www.w3.org/2005/xpath-functions"
    exclude-result-prefixes="#all"
    expand-text="yes">
    
    <xsl:mode on-no-match="shallow-copy"/>
    
    <xsl:template match="example">
        <xsl:copy>{
            function-lookup(xs:QName(function), count(arguments/arg))
            =>
            apply(array { arguments/arg })
        }</xsl:copy>
    </xsl:template>
    
    <xsl:template match="/" name="xsl:initial-template">
        <xsl:next-match/>
        <xsl:comment xmlns:saxon="http://saxon.sf.net/">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>

input sample:

<root>
    <example>
        <function>fn:concat</function>
        <arguments>
            <arg>a</arg>
            <arg>b</arg>
            <arg>c</arg>
        </arguments>
    </example>
</root>

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>
    <example>abc</example>
</root>

History

#1 Updated by Michael Kay 21 days 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 Array.map (<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.

#2 Updated by Debbie Lockett 9 days ago

  • Assignee set to Debbie Lockett

#3 Updated by Michael Kay 7 days 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.

Please register to edit this issue

Also available in: Atom PDF Tracking page