Re: [xsl] Windows-style CRLF in text output

Subject: Re: [xsl] Windows-style CRLF in text output
From: Abel Braaksma <>
Date: Thu, 10 Jul 2008 21:54:49 +0200
Michael Kay wrote:
<snip />, whereas if it contains


then it will write xDxA. Of course there's plenty of scope for the Java
runtime and the operating system to change that before it hits the disk. In
fact one way to achieve what you want might be to write a Java Writer that
adjusts the line endings as required, and send the transformation output to
that Writer.

An alternative approach, along the lines of Dan Appleman's infamous "it CAN be done in language xxx", could be to not write xA or xD at all, instead use a Unicode Private Use character. Then, after serializing, these "newlines" can be converted by either reprocessing it as unparsed-text with XSLT 2.0 (and writing it as method="text"), using sed on Unix or Perl or Ruby or Java or whatever you like to use to replace these Private Use characters to your type of line endings.

That way you bypass the XML line ending normalization.

One additional note, if I recall correctly, using a character map, you bypass the normalization process too and the newline character that you can create that way is not allowed to be changed... at least that's what I believe that the spec is saying.

-- Abel --

Current Thread