Output should not include extraneous newlines when indent is off
authorLaurence Rowe <l@lrowe.co.uk>
Thu, 16 Jun 2011 17:44:06 +0000 (18:44 +0100)
committerDaniel Veillard <veillard@redhat.com>
Thu, 16 Aug 2012 10:05:47 +0000 (18:05 +0800)
Hence matching behaviour of xmlSaveOption XML_SAVE_FORMAT off.
This affects only one of the regression tests

libxslt/xsltutils.c
tests/docs/bug-173.xml [new file with mode: 0644]
tests/general/Makefile.am
tests/general/bug-173.out [new file with mode: 0644]
tests/general/bug-173.xsl [new file with mode: 0644]
tests/keys/month.out

index 4ee124c..bc94266 100644 (file)
@@ -1587,13 +1587,14 @@ xsltSaveResultTo(xmlOutputBufferPtr buf, xmlDocPtr result,
            while (child != NULL) {
                xmlNodeDumpOutput(buf, result, child, 0, (indent == 1),
                                  (const char *) encoding);
-               if ((child->type == XML_DTD_NODE) ||
+               if (indent && ((child->type == XML_DTD_NODE) ||
                    ((child->type == XML_COMMENT_NODE) &&
-                    (child->next != NULL)))
+                    (child->next != NULL))))
                    xmlOutputBufferWriteString(buf, "\n");
                child = child->next;
            }
-           xmlOutputBufferWriteString(buf, "\n");
+           if (indent)
+                       xmlOutputBufferWriteString(buf, "\n");
        }
        xmlOutputBufferFlush(buf);
     }
diff --git a/tests/docs/bug-173.xml b/tests/docs/bug-173.xml
new file mode 100644 (file)
index 0000000..f3f286e
--- /dev/null
@@ -0,0 +1 @@
+<root/>
index b6c738b..f7fdea9 100644 (file)
@@ -180,6 +180,7 @@ EXTRA_DIST = \
     bug-170.out bug-170.xsl \
     bug-171.out bug-171.xsl \
     bug-172.out bug-172.xsl \
+    bug-173.out bug-173.xsl \
     character.out character.xsl \
     character2.out character2.xsl \
     itemschoose.out itemschoose.xsl \
diff --git a/tests/general/bug-173.out b/tests/general/bug-173.out
new file mode 100644 (file)
index 0000000..d39c5bc
--- /dev/null
@@ -0,0 +1 @@
+<!--Comment--><root/>
\ No newline at end of file
diff --git a/tests/general/bug-173.xsl b/tests/general/bug-173.xsl
new file mode 100644 (file)
index 0000000..deb89e8
--- /dev/null
@@ -0,0 +1,11 @@
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+<xsl:output indent="no" omit-xml-declaration="yes"/>
+
+<xsl:template match="/">
+  <!-- Output should not include extraneous newlines when indent is off -->
+  <xsl:comment>Comment</xsl:comment>
+  <root/>
+</xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file
index 99c3a3d..088c1c7 100644 (file)
@@ -4,4 +4,4 @@
   <month>December</month>
   <month>December</month>
   <month/>
-</dates>
+</dates>
\ No newline at end of file