xsl-list
[Top] [All Lists]

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

2018-05-29 15:59:23


On 29 May 2018, at 09:19, cmarchand(_at_)oxiane(_dot_)com 
<xsl-list-service(_at_)lists(_dot_)mulberrytech(_dot_)com> 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

--~----------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
EasyUnsubscribe: http://lists.mulberrytech.com/unsub/xsl-list/1167547
or by email: xsl-list-unsub(_at_)lists(_dot_)mulberrytech(_dot_)com
--~--

<Prev in Thread] Current Thread [Next in Thread>