[xml/sgml-pkgs] Bug#718535: libxslt1.1: missing newlines with indent="no"
Vincent Lefevre
vincent at vinc17.net
Fri Aug 2 00:19:16 UTC 2013
Package: libxslt1.1
Version: 1.1.28-2
Severity: important
When indent="no" is used, some newline characters are missing,
in particular at the end of the file. This is a regression. And
using indent="yes" is not an acceptable workaround as it is not
safe, as said by the XSLT spec:
NOTE: It is usually not safe to use indent="yes" with document types
that include element types with mixed content.
For instance, for the following "copy.xsl" file:
<?xml version="1.0" encoding="utf-8"?>
<!-- Comment 1 -->
<!-- Comment 2 -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
I get with bash:
vinc17 at xvii:~$ xsltproc copy.xsl copy.xsl
<?xml version="1.0"?>
<!-- Comment 1 --><!-- Comment 2 --><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="no"/>
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>vinc17 at xvii:~$
The newline characters before and after the root element should be
preserved, possibly squashed. And when a DOCTYPE line is generated,
there should be a newline character after it. AFAIK the XSLT spec
says nothing about these newlines (and more generally spaces) since
they have no meaning in the XML tree. So, let's see the pros and cons.
Pros: readability; better usability with line-based tools, such as
"diff" (to compare generated output), "svn blame" and so on.
Cons: very little wasted space. But this should be not be significant
in practice, compared to the whole document.
Also, if the user has added newlines in the source, this may be for a
good reason.
More importantly, the final newline character is missing, which can
break some tools. Let's recall that for POSIX, a text file must end
with a newline character, and POSIX tools are not required to work
without it.
-- System Information:
Debian Release: jessie/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 3.10-1-amd64 (SMP w/2 CPU cores)
Locale: LANG=POSIX, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages libxslt1.1 depends on:
ii libc6 2.17-91
ii libgcrypt11 1.5.3-1
ii libxml2 2.9.1+dfsg1-2
ii multiarch-support 2.17-91
libxslt1.1 recommends no packages.
libxslt1.1 suggests no packages.
-- no debconf information
-- debsums errors found:
sh: 1: /usr/sbin/dpkg-divert: not found
More information about the debian-xml-sgml-pkgs
mailing list