[ 
https://issues.apache.org/jira/browse/XALANJ-2750?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mukul Gandhi reassigned XALANJ-2750:
------------------------------------

    Assignee: Mukul Gandhi

> java.lang.ClassCastException: org.apache.xpath.objects.XNodeSet cannot be 
> cast to org.apache.xpath.objects.XPathMap when processing XDM array 
> containing XDM maps
> -----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: XALANJ-2750
>                 URL: https://issues.apache.org/jira/browse/XALANJ-2750
>             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
>         Environment: Windows 11, Java 8
>            Reporter: Martin Honnen
>            Assignee: Mukul Gandhi
>            Priority: Major
>         Attachments: json-doc-input-sample1.xml, process-xdm-array-test1.xsl
>
>
> This is a bug report against the XSLT 3 development branch of Apache Xalan.
> I have tried to use the recently implemented json-doc XPath 3.1 function but 
> the following code to process a JSON document being an array of objects 
> (which in XDM 3.1 should be an array of maps) results in an error 
> java.lang.ClassCastException: org.apache.xpath.objects.XNodeSet cannot be 
> cast to org.apache.xpath.objects.XPathMap.
>  
> With Saxon HE 12 it outputs e.g.
> {code:java}
> <tags>
>    <tag>og:POP2018</tag>
>    <tag>og:LHW1910</tag>
>    <tag>og:WHI2010</tag>
>    <tag>og:WHI2016</tag>
>    <tag>og:RHY1908</tag>
>    <tag>og:POW1994</tag>
>    <tag>og:WIN1850</tag>
>    <tag>og:RON2009</tag>
>    <tag>og:MAC1897</tag>
>    <tag>og:MAC1930</tag>
>    <!-- snipped here -->
> </tags>{code}
>  
> Running the XSLT shown below against an XML input as e.g.
> {code:java}
> <root>
>   <url>https://api.zotero.org/groups/4625439/tags</url>
> </root>{code}
> shows the cited error with Xalan
>  
> {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="url">
>     <tags>
>       <xsl:variable name="xdm-array" select="json-doc(.)"/>
>       <xsl:for-each select="for $pos in (1 to array:size($xdm-array)) return 
> array:get($xdm-array, $pos)">
>         <tag>
>           <xsl:value-of select="map:get(., 'tag')"/>
>         </tag>
>       </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}
>  



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