SaxonJS 726,956 2.7 (17 October 2024; 3.0 is in beta) runs XSLT 3.0 in browsers and Node.js 2,131 , free but not open source (Saxonica's licence). It executes a compiled SEF file (JSON), made by npm 2,036 's xslt3 command or Saxon-EE 726,956 . This stylesheet uses maps, grouping and JSON output, all beyond XSLT 1.0:
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xsl:param name="min" as="xs:double" select="0"/>
<xsl:output method="json"/>
<xsl:template match="/catalog">
<xsl:map>
<xsl:for-each-group select="book[.//price >= $min]" group-by=".//availability">
<xsl:map-entry key="current-grouping-key()"
select="array { current-group()/string(@id) }"/>
</xsl:for-each-group>
</xsl:map>
</xsl:template>
</xsl:stylesheet>import SaxonJS from "saxon-js";
const result = await SaxonJS.transform({
stylesheetFileName: "shelf3.sef.json",
sourceFileName: "booknest-catalog.xml",
stylesheetParams: { min: 20 },
destination: "serialized",
}, "async");
console.log("SaxonJS", SaxonJS.getProcessorInfo().productVersion, result.principalResult);npm install --silent --no-fund saxon-js@2.7.0 xslt3@2.7.0
npx xslt3 -xsl:shelf3.xsl -export:shelf3.sef.json -nogo -relocate:on
node transform.mjsOutput
SaxonJS 2.7 {"in-stock":["b2","b6"],"out-of-stock":["b3"]}JavaScript numbers arrive as xs:double: as="xs:decimal" failed with XPTY0004. In browsers, load SaxonJS2.rt.js from saxonica.com and call SaxonJS.transform() with stylesheetLocation.