Martin Honnen created XALANJ-2753:
-------------------------------------
Summary: iXPath 3.1 instance of map(*) returns false for result of
parse-json called on JSON object
Key: XALANJ-2753
URL: https://issues.apache.org/jira/browse/XALANJ-2753
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
Affects Versions: The Latest Development Code
Reporter: Martin Honnen
This is a bug report on the Xalan Java XSLT 3 development branch.
While exploring the XPath 3.1 features to represent JSON arrays and objects as
XDM 3.1 arrays and maps I have found that the XPath 3.1 instance of operator in
Xalan currently reports true for testing the result of parse-json of a JSON
array as the sequence type array(*) but returns false for testing the result of
parse-json of a JSON object as the sequence type map(*).
Sample XSLT code:
{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="array">
<array-test>
<xsl:variable name="xdm-array" select="parse-json(.)"/>
<array-instance-of-test>
<xsl:value-of select="$xdm-array instance of array(*)"/>
</array-instance-of-test>
</array-test>
</xsl:template>
<xsl:template match="map">
<map-test>
<xsl:variable name="xdm-map" select="parse-json(.)"/>
<map-instance-of-test>
<xsl:value-of select="$xdm-map instance of map(*)"/>
</map-instance-of-test>
</map-test>
</xsl:template>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates/>
<xsl:comment>Run with <xsl:value-of
select="system-property('xsl:vendor')"/> at <xsl:value-of
select="current-dateTime()"/></xsl:comment>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
{code}
Sample XML code:
{code:java}
<root>
<map>{ "name" : "foo", "data" : [3,2,1] }</map>
<array>[ { "name" : "foo", "value" : 3.2 } ]</array>
</root>{code}
Current output with Xalan:
{code:java}
<map-test>
<map-instance-of-test>false</map-instance-of-test>
</map-test>
<array-test>
<array-instance-of-test>true</array-instance-of-test>
</array-test>{code}
Expected output:
{code:java}
<map-test>
<map-instance-of-test>true</map-instance-of-test>
</map-test>
<array-test>
<array-instance-of-test>true</array-instance-of-test>
</array-test>{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]