Project

Profile

Help

Is there a way to indent output with output method 'adaptive'?

Added by Martin Honnen over 6 years ago

It seems the serialization spec https://www.w3.org/TR/xslt-xquery-serialization-31/#ADAPTIVE_INDENT says that the output method 'adaptive' does not take the 'indent' option into account:

The indent and suppress-indentation parameters are not directly applicable to the Adaptive output method

On the other hand it seems desirable to me to allow indentation of complex maps output with the 'adaptive' method and XQuery implementations like BaseX or Altova XMLSpy for instance do indent the result of

declare namespace output = "http://www.w3.org/2010/xslt-xquery-serialization";

declare option output:method 'adaptive';
declare option output:indent 'yes';

map { 'foo' : map { 'bar':1, 'baz':'string'}, 'test': true()}

and output something like

map {
  "foo": map {
    "bar": 1,
    "baz": "string"
  },
  "test": true()
}

Saxon 9.8 (tested with HE and EE) however doesn't indent and outputs

map{"foo":map{"bar":1,"baz":"string"},"test":true()}

I have looked through Saxon specific options in https://www.saxonica.com/html/documentation/extensions/output-extras/ but haven't found anything.

Is there any way to get Saxon to indent the result when using output method 'adaptive'?


Replies (1)

RE: Is there a way to indent output with output method 'adaptive'? - Added by Michael Kay over 6 years ago

I think the answer to your question is no, there is no way to achieve this in Saxon; and this is conformant with the W3C spec.

Whether it would also be conformant to take account of the "indent" option is not entirely clear; there could be different interpretations of this. On the whole, since the spec isn't prescriptive about whitespace, I think it probably would be.

    (1-1/1)

    Please register to reply