Re: [xsl] pretty printing - having CRLF instead of LF

Subject: Re: [xsl] pretty printing - having CRLF instead of LF
From: "Michael Kay mike@xxxxxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 29 May 2018 20:59:18 -0000
> On 29 May 2018, at 09:19, cmarchand@xxxxxxxxxx
<xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> If you use a Java based XSLT Processor, you may change the system property
:
> System.setProperty("line.separator", "\r\n");
>

This may affect the behavior of some Java XSLT processors, but it won't affect
the behavior of Saxon. I don't see anything in the JAXP specs that says it's
relevant.

Note that according to the 3.1 serialization spec (I haven't checked earlier
versions but I suspect they're the same), the serializer has discretion to use
CRLF rather than LF as a line ending when inserting indentation, but it has no
license to do so when outputting the content of text (or attribute) nodes in
the actual transformation result. A newline (LF) character appearing in a text
node must be serialized as a newline character; a CR character appearing in a
text node must be serialized as &#x0D; or equivalent.

I would suggest sending the transformation result to a StreamResult that
contains a custom implementation of OutputStream that translates LF to CRLF.

Michael Kay
Saxonica

Current Thread