[ 
https://issues.apache.org/jira/browse/XALANJ-2808?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17941225#comment-17941225
 ] 

Mukul Gandhi commented on XALANJ-2808:
--------------------------------------

[~martin.honnen]
You're probably right.

For now, I'd like to suggest a workaround for this use case with Xalan-J's XSL 
3 implementation as follows (using an XPath inline function expression wrapper 
to invoke an XSL stylesheet function):

<?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:fn0="http://fn0";
                        exclude-result-prefixes="xs fn0">                       
                                                
  
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="/">
     <result>
            <xsl:value-of select="fold-left(1 to 5, 0, function($a as 
xs:integer, $b as xs:integer) as xs:integer { fn0:add($a, $b) })"/>
         </result>
  </xsl:template>
  
  <xsl:function name="fn0:add" as="xs:integer">
        <xsl:param name="a" as="xs:integer"/>
        <xsl:param name="b" as="xs:integer"/>
        <xsl:sequence select="$a + $b"/>
  </xsl:function>

</xsl:stylesheet>

Hoping that, Xalan-J's XSL 3 implementation shall solve the bug report provided 
by you within this jira issue.

Many thanks.

> can't pass XSLT defined xsl:function to fold-left:  FORG0006 : The third 
> argument to function call fn:fold-left is not a function item, or cannot be 
> coerced to a function item
> -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2808
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2808
>             Project: XalanJ2
>          Issue Type: Bug
>      Security Level: No security risk; visible to anyone(Ordinary problems in 
> Xalan projects.  Anybody can view the issue.) 
>          Components: transformation, Xalan, XPath-function
>    Affects Versions: The Latest Development Code
>         Environment: Java 8, Windows 11
>            Reporter: Martin Honnen
>            Assignee: Mukul Gandhi
>            Priority: Major
>         Attachments: fold-left-pass-user-defined-xslt-function-test1.xsl, 
> fold-left-seq-of-stylesheets-transform4.xsl
>
>
> This is a bug report against the XSLT 3 development branch of Xalan.
> I am trying to pass a function defined in XSLT with xsl:function to the 
> higher-order function fold-left but Xalan doesn't seem to support that so 
> far, I get " FORG0006 : The third argument to function call fn:fold-left is 
> not a function item, or cannot be coerced to a function item".
> An XSLT stylesheet is attached, it can be run against the file 
> src/test/resources/fn_fold_left/test1_a.xml in the Xalan branch.
> In my view the function call should work and the result should be e.g.
> {code:xml}
> <?xml version="1.0" encoding="UTF-8"?>
> <result>
>    <val1>210</val1>
>    <val2>210</val2>
> </result>
> {code}
> I get the same problem with more complex code trying to use the transform 
> function, the stylesheet is also attached.
>  
>  
>  



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@xalan.apache.org
For additional commands, e-mail: dev-h...@xalan.apache.org

Reply via email to