Martin Honnen created XALANJ-2740:
-------------------------------------

             Summary: map:for-each(parse-json(...), ..) gives error FORG0006 : 
The 1st argument to function call map:for-each, is not a map
                 Key: XALANJ-2740
                 URL: https://issues.apache.org/jira/browse/XALANJ-2740
             Project: XalanJ2
          Issue Type: Bug
      Security Level: No security risk; visible to anyone (Ordinary problems in 
Xalan projects.  Anybody can view the issue.)
          Components: Xalan-CmdLine
    Affects Versions: The Latest Development Code
         Environment: Windows 11, Java 8
            Reporter: Martin Honnen
         Attachments: map-for-each-test3.xsl, xml-sample-with-json-data2.xml

This is a bug report on the XSLT 3.0 development branch of Xalan.

In my attempt to try the new implementation of parse-json and map function I 
have written code like
{code:java}
  <xsl:template match="data">
    <xsl:copy>
      <xsl:value-of select="map:for-each(parse-json(.), function($k, $v) { $k 
|| ' : ' || $v })"/>
    </xsl:copy>
  </xsl:template>{code}
 

but that gives an error "FORG0006 : The 1st argument to function call 
map:for-each, is not a map".

As a workaround it appears that using a variable works:
{code:java}
  <xsl:template match="data">
    <xsl:copy>
      <xsl:variable name="map1" select="parse-json(.)"/>
      <xsl:value-of select="map:for-each($map1, function($k, $v) { $k || ' : ' 
|| $v })"/>
    </xsl:copy>
  </xsl:template>{code}
 

But it seems to me that the original expression should work too.

Full files 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