Project

Profile

Help

Does the Python API of SaxonC 11 intentionally restrict captured result to PyXdmNode and that way exclude XdmMap/XdmArray/JSON results?

Added by Martin Honnen almost 3 years ago

The documentation of https://www.saxonica.com/saxon-c/doc11/html/saxonc.html#PyXsltExecutable-get_result_documents says:

Returns: dict [str, PyXdmNode]: Dict of the key, value pair. Indexed by the absolute URI of each result document, and the corresponding value is an PyXdmNode object containing the result document (as an in-memory tree, without serialization).

Isn't that rather restrictive to say it is a dict with PyXdmNode values?

In general an XSLT transformation can also return JSON/XDM maps or arrays and that way any attempt to capture e.g. <xsl:result-document href="result-1.json" method="json"><xsl:sequence select="map { 'value' : 'foo' }"/></xsl:result-document> would fail as it doesn't construct any node.

Indeed, trying to use such a construct with both set_capture_result_documents(True) and set_result_as_raw_value(True) on the PyXsltExecutable seems to lead to an error "Cannot serialize a map using this output method".

Error at char 6 in expression in xsl:sequence/@select on line 21 column 59
  SENR0001  Cannot serialize a map using this output method
  In template rule with match="item" on line 18 of
     invoked by xsl:apply-templates at #14
  In template rule with match="root" on line 12 of
     invoked by built-in template rule (shallow-copy)
  In template rule with match="/" on line 25 of
{'item-1.json': }

Is that a design flaw in the API or a necessary restriction due to limitations of SaxonC?


Replies (1)

    (1-1/1)

    Please register to reply