After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 705489 - Behavior of indent xsl:output attribute should be documented
Behavior of indent xsl:output attribute should be documented
Status: RESOLVED OBSOLETE
Product: libxslt
Classification: Platform
Component: general
1.1.x
Other Linux
: Normal normal
: ---
Assigned To: Daniel Veillard
libxml QA maintainers
Depends on:
Blocks:
 
 
Reported: 2013-08-05 10:56 UTC by Vincent Lefevre
Modified: 2021-07-05 11:00 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Vincent Lefevre 2013-08-05 10:56:21 UTC
I had some XSLT stylesheets with indent="no", and the fix of bug 652766 introduced a change in the behavior. 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@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@xvii:~$ 

The missing newline character after each top-level node (comments, processing instructions, root element, and also the DOCTYPE line when there is one) is rather annoying for various reasons: readability, mandatory newline at the end of the file to regard it as a POSIX text file, usability with line-based tools, such as "diff" (to compare generated output), "svn blame" and so on...

It appears that removing the indent="no" allows one to get the old behavior for the top-level nodes, while still avoiding indentation in the contents (which is not always safe for some applications). I think that it is OK, though it may be a bit confusing as the XSLT spec[*] says that the default indent value is no (I don't think different behavior between indent="no" and no indent attribute is incorrect, since whitespace between top-level nodes is unspecified by the XSLT spec, as having no influence on how the XML document is to be interpreted). But this should be documented; currently it isn't in the man pages at least.

[*] http://www.w3.org/TR/xslt says: "If the indent attribute has the value yes, then the xml output method may output whitespace in addition to the whitespace in the result tree (possibly based on whitespace stripped from either the source document or the stylesheet) in order to indent the result nicely; if the indent attribute has the value no, it should not output any additional whitespace. The default value is no."

BTW, related to this, one doesn't get a newline character after a top-level processing instruction, even if indent="no" isn't used. This is bug 439825.
Comment 1 GNOME Infrastructure Team 2021-07-05 11:00:57 UTC
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org.
As part of that, we are mass-closing older open tickets in bugzilla.gnome.org
which have not seen updates for a longer time (resources are unfortunately
quite limited so not every ticket can get handled).

If you can still reproduce the situation described in this ticket in a recent
and supported software version, then please follow
  https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines
and create a new ticket at
  https://gitlab.gnome.org/GNOME/libxslt/-/issues/

Thank you for your understanding and your help.