- From: Mukul Gandhi <gandhi.mukul@gmail.com>
- Date: Sun, 10 Aug 2025 23:14:18 +0530
- To: public-xslt-40@w3.org
Hi all, I apologize that, I'm writing this mail on this list and this question seems to be off-topic for this list. I've a question about XPath 3.1 function fn:json-to-xml and its duplicates resolution option 'retain', where all the XDM map's keys with same name have to be available within fn:json-to-xml's XML result serialization. Please consider following XSLT 3.0 stylesheet example using XPath 3.1 function fn:json-to-xml. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="3.0"> <xsl:output method="xml" indent="yes"/> <xsl:variable name="jsonStr" as="xs:string"> { "a" : 1, "b" : {"x" : 10, "y" : 11, "x" : 12}, "b" : 3, "a" : 4 } </xsl:variable> <xsl:template match="/"> <xsl:sequence select="json-to-xml($jsonStr, map{'duplicates' : 'retain'})"/> </xsl:template> </xsl:stylesheet> Saxon-HE 12.5 XSLT 3.0 processor emits following XSL transform output for this stylesheet: <?xml version="1.0" encoding="UTF-8"?> <map xmlns="http://www.w3.org/2005/xpath-functions"> <number key="a">1</number> <map key="b"> <number key="x">10</number> <number key="y">11</number> <number key="x">12</number> </map> <number key="b">3</number> <number key="a">4</number> </map> Whereas, Apache Xalan-J's XSLT 3.0 development code, for this stylesheet produces following result: <?xml version="1.0" encoding="UTF-8"?><map xmlns="http://www.w3.org/2005/xpath-functions"> <number key="a">1</number> <number key="a">4</number> <map key="b"> <number key="x">10</number> <number key="x">12</number> <number key="y">11</number> </map> <number key="b">3</number> </map> I think, that both of above mentioned XSL transformation results for the two mentioned XSLT processors looks similar, but they're not exactly same. Saxon's XSL transformation result for this example, follows XDM map's key order sequence as present within JSON input document, whereas, Xalan-J's XSL transformation result has XDM map keys with same name adjacent to each other. My question is, whether Xalan-J's result for this XSL stylesheet example, compliant to XPath 3.1 spec for the function fn:json-to-xml? Many thanks in advance for any answers. -- Regards, Mukul Gandhi
Received on Sunday, 10 August 2025 17:44:38 UTC