Project

Profile

Help

Bug #2512

closed

Adaptive and JSON output methods from the XSLT command line

Added by Michael Kay over 8 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Command Line
Sprint/Milestone:
-
Start date:
2015-12-01
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.7
Fix Committed on Branch:
9.7
Fixed in Maintenance Release:
Platforms:

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

Also available in: Atom PDF