Bug #2512
closedAdaptive and JSON output methods from the XSLT command line
100%
Description
XSLT 3.0 / XQuery 3.1 introduce two new serialization methods: "json" and "adaptive". It's currently not possible to use these when running XSLT from the command line.
In the past, the result of the initial template in XSLT was always converted to a document node. For example, given
<xsl:template match="/">
<xsl:sequence select="1 to 5"/>
</xsl:template>
the result would be a document node containing a single text node whose string value was the string "1 2 3 4 5".
This makes it impossible to do
<xsl:template match="/">
<xsl:sequence select="map{'London':3, 'Paris':8}"/>
</xsl:template>
because a map cannot be converted to a string and added to a document in this way. To remedy this, XSLT 3.0 adds the attribute
<xsl:output build-tree="no"/>
which suppresses the construction of the document. The spec also says that if the output method is "json" or "adaptive", then this should be the default.
Saxon 9.7 does not yet implement the build-tree attribute on xsl:output. It does allow the building of the tree to be suppressed when using the s9api interface, for example
XdmValue result = transformer.applyTemplates(input)
returns the "raw" result of the initial template, which may be (for example) a sequence of integers or a map. But there is no way of invoking this functionality from the command line.
Please register to edit this issue