xsl-list
[Top] [All Lists]

Re: [xsl] XSLT engines and terminal newline

2006-09-19 08:52:09
When I do an XSLT transformation with xsltproc, the output is
always newline-terminated (final byte is a newline character).
When I do the same transformation with Saxon 6.5, the output is
not newline-terminated.

For most purposes the difference doesn't matter. But to diff and
some other text-processing tools, it does (diff considers any line
that doesn't end with a newline to be an "incomplete line"; it
goes ahead processes such a line as if they did end in a newline,
but emits a "No newline at end of file" message in the diff).

I know I can make changes within my stylesheet to ensure that the
terminal newline gets added to the Saxon output, but the problem
is that if I then use the same stylesheet with xsltproc, I end up
with two newlines at the end of the file (and so an unnecessary
blank line at the end). I also know that for the case of XML
output, I can do a postprocessing step to run it through a tool
that produces canonical XML -- which will ensure that it ends with
single newline -- but that does me no good for HTML output.

Has anybody else run into this issue? Any suggestions about how to
deal with it?



It's never been an issue for me (I'm willing to live with the issue in my
diffs), but I have a suggestion: Pass a parameter to the stylesheet to tell
it whether to add a newline. If you have other processor-specific issues,
you could pass the name of the processor as a parameter and set all kinds of
things accordingly.

Jay Bryant
Bryant Communication Services



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--