summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLaurence Rowe <l@lrowe.co.uk>2011-06-16 18:44:06 +0100
committerDaniel Veillard <veillard@redhat.com>2012-08-16 18:05:47 +0800
commit1eae5e8cbcad26415fe229885244316387bc15d9 (patch)
treecabc380341ec76bc629bae164b0c3deb38b1162b
parent9e5d4dc5c0c7a4810eee28d1cdebc86e587f76bf (diff)
downloadlibxslt-1eae5e8cbcad26415fe229885244316387bc15d9.tar.gz
libxslt-1eae5e8cbcad26415fe229885244316387bc15d9.tar.bz2
libxslt-1eae5e8cbcad26415fe229885244316387bc15d9.zip
Output should not include extraneous newlines when indent is off
Hence matching behaviour of xmlSaveOption XML_SAVE_FORMAT off. This affects only one of the regression tests
-rw-r--r--libxslt/xsltutils.c7
-rw-r--r--tests/docs/bug-173.xml1
-rw-r--r--tests/general/Makefile.am1
-rw-r--r--tests/general/bug-173.out1
-rw-r--r--tests/general/bug-173.xsl11
-rw-r--r--tests/keys/month.out2
6 files changed, 19 insertions, 4 deletions
diff --git a/libxslt/xsltutils.c b/libxslt/xsltutils.c
index 4ee124c7..bc942668 100644
--- a/libxslt/xsltutils.c
+++ b/libxslt/xsltutils.c
@@ -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
index 00000000..f3f286ea
--- /dev/null
+++ b/tests/docs/bug-173.xml
@@ -0,0 +1 @@
+<root/>
diff --git a/tests/general/Makefile.am b/tests/general/Makefile.am
index b6c738bd..f7fdea9c 100644
--- a/tests/general/Makefile.am
+++ b/tests/general/Makefile.am
@@ -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
index 00000000..d39c5bcb
--- /dev/null
+++ b/tests/general/bug-173.out
@@ -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
index 00000000..deb89e88
--- /dev/null
+++ b/tests/general/bug-173.xsl
@@ -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
diff --git a/tests/keys/month.out b/tests/keys/month.out
index 99c3a3d5..088c1c7b 100644
--- a/tests/keys/month.out
+++ b/tests/keys/month.out
@@ -4,4 +4,4 @@
<month>December</month>
<month>December</month>
<month/>
-</dates>
+</dates> \ No newline at end of file