php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #43754 XMLWriter::fullEndElement produces wrong indentation
Submitted: 2008-01-04 21:20 UTC Modified: 2008-01-09 09:47 UTC
From: karel dot smutny at gmail dot com Assigned:
Status: Closed Package: XML Writer
PHP Version: 5.2.5 OS: Windows XP SP2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: karel dot smutny at gmail dot com
New email:
PHP Version: OS:

 

 [2008-01-04 21:20 UTC] karel dot smutny at gmail dot com
Description:
------------
fullEndElement() procedure produces wrong indentation when called setIndent(true). There is no new line and indentation before tag  following another end tag produced by fullEndElement().

Reproduce code:
---------------
  $xml = new XMLWriter();
  $xml->openMemory();
  $xml->setIndent(true);
  
  $xml->startElement('body');
  $xml->startElement('div');
  $xml->writeAttribute('id', 'all');
  $xml->startElement('div');
  $xml->writeAttribute('id', 'header');
  $xml->fullEndElement();
  $xml->startElement('div');
  $xml->writeAttribute('id', 'content');
  $xml->fullEndElement();
  $xml->startElement('div');
  $xml->writeAttribute('id', 'footer');
  $xml->fullEndElement();
  $xml->fullEndElement();
  $xml->fullEndElement();
  echo $xml->outputMemory();

Expected result:
----------------
<body>
 <div id="all">
  <div id="header"></div>  
  <div id="content"></div>  
  <div id="footer"></div>
 </div>
</body>

Actual result:
--------------
<body>
 <div id="all">
  <div id="header"></div>  <div id="content"></div>  <div id="footer"></div></div></body>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-01-08 21:13 UTC] felipe@php.net
AFAIK, this is a bug in Libxml. Seeing the source in 
http://cvs.gnome.org/viewcvs/libxml2/xmlwriter.c?rev=1.37&view=markup
in xmlTextWriterFullEndElement() is missing:

    if (writer->indent) {
        count = xmlOutputBufferWriteString(writer->out, "\n");
        sum += count;
    }

That is founded in xmlTextWriterEndElement() (called from endElement() in PHP extension), and works fine. :)
 [2008-01-09 09:47 UTC] felipe@php.net
I reported this bug, and already fixed in SVN (libxml).

http://bugzilla.gnome.org/show_bug.cgi?id=508156
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC