Bug #74492 [Opn->Ana]: XMLWriter adds indent between mixed child nodes.

From: Date: Mon, 02 Apr 2018 22:05:28 +0000
Subject: Bug #74492 [Opn->Ana]: XMLWriter adds indent between mixed child nodes.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-214571@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74492&edit=1 ID: 74492 Updated by: cmb@php.net Reported by: subjective@php.net Summary: XMLWriter adds indent between mixed child nodes. -Status: Open +Status: Analyzed Type: Bug Package: XML Writer PHP Version: 7.1.4 Block user comment: N Private report: N New Comment: ext/xmlwriter is a rather thin layer over libxml2's xmlwriter module[1], and this is the way that xmlTextWriterSetIndent() works (currently). It might be worthwhile to report this issue upstream[2], but pretty printing might better be left to specialized tools, anyway. In my opinion, it is best to make this a documentation issue, and to convey that ::setIndent() is not necessarily suitable for mixed content. By the way, XMLWriter::setIndent() expects a boolean argument, not an integer. [1] <http://xmlsoft.org/html/libxml-xmlwriter.html> [2] <https://bugzilla.gnome.org/buglist.cgi?product=libxml2> Previous Comments: ------------------------------------------------------------------------ [2017-04-23 10:58:55] subjective@php.net Description: ------------ XMLWriter adds the defined indent between mixed child nodes. This will change the meaning if the text nodes do not contain leading/trailing whitespaces. This does not happen if the indent is set to zero. Test script: --------------- <?php $_ = new XMLWriter(); $_->openMemory(); $_->setIndent(2); $_->startDocument(); $_->startElement('p'); $_->text('before'); $_->writeElement('a', 'element'); $_->text('after'); $_->endElement(); $_->endDocument(); echo $_->outputMemory(); Expected result: ---------------- <?xml version="1.0"?> <p>before<a>element</a>after</p> Actual result: -------------- <?xml version="1.0"?> <p>before <a>element</a> after</p> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74492&edit=1

« previous php.bugs (#214571) next »