Martin Honnen created XALANJ-2751:
-------------------------------------
Summary: NullPointerException when using XDM 3.1 function map:get
on XDM map created with parse-json
Key: XALANJ-2751
URL: https://issues.apache.org/jira/browse/XALANJ-2751
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, Xalan-CmdLine
Environment: Java 8, Windows 11
Reporter: Martin Honnen
Attachments: parse-json-map-get-test1.xsl,
xml-sample-with-json-data3.xml
This is a bug report on the Xalan Java XSLT 3 development branch.
While exploring the support for dealing with JSON data in the forms of XDM 3.1
maps and arrays I found a simple test case causing a
java.lang.NullPointerException.
Sample XSLT:
{code:java}
<?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:map="http://www.w3.org/2005/xpath-functions/map"
xmlns:array="http://www.w3.org/2005/xpath-functions/array"
exclude-result-prefixes="xs map array">
<xsl:output method="xml" indent="yes"/>
<xsl:template match="json">
<tags>
<xsl:variable name="xdm-map" select="parse-json(.)"/>
<xsl:for-each select="map:get($xdm-map, 'data')">
<value>
<xsl:value-of select="."/>
</value>
</xsl:for-each>
</tags>
<xsl:comment>Run with <xsl:value-of
select="system-property('xsl:vendor')"/> at <xsl:value-of
select="current-dateTime()"/></xsl:comment>
</xsl:template>
</xsl:stylesheet>
{code}
Sample XML:
{code:java}
<root>
<json>{ "name" : "foo", "data" : [3,2,1] }</json>
</root>{code}
Output:
{noformat}
<?xml version="1.0" encoding="UTF-8"?>
file:///C:/Users/marti/IdeaProjects/xalan-java/../../OneDrive/Documents/xslt/blog-xslt-3-by-example/xalan-xslt3-tests/parse-json-map-get-test1.xsl;
Zeilennummer14; Spaltennummer56; java.lang.NullPointerException{noformat}
Expected output is e.g.
{code:java}
<?xml version="1.0" encoding="UTF-8"?>
<tags>
<value>3 2 1</value>
</tags>
{code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]