Re: [xml] Duplicate end-tags in htmlNodeDump



On Mon, May 07, 2001 at 07:13:28PM +0000, Bjorn Reese wrote:
I am failing to understand the following sequence in HTMLtree.c
/ htmlNodeDump. More accurately, I cannot see the point with the
last three lines.

    if (!htmlIsAutoClosed(doc, cur)) {
        xmlBufferWriteChar(buf, "</");
        xmlBufferWriteCHAR(buf, cur->name);
        xmlBufferWriteChar(buf, ">");
    }
    xmlBufferWriteChar(buf, "</");
    xmlBufferWriteCHAR(buf, cur->name);
    xmlBufferWriteChar(buf, ">");

 Dohhh :-(

htmlIsAutoClosed returns true "if a tags is autoclosed by one of
it's children" (if 'autoclosed' implies that an end-tag is inserted
then I suspect that two end-tags will be inserted in this case, but
I have not verified this). If htmlIsAutoClosed returns false, then
two identical end-tags will be inserted. Why?

My problem is that much of my HTML output have two end-tags per
start-tag, which is fatal for embedded tags. Removing the last
three lines above, seemed to solve this problem. As I was under
time pressure, I did not had time to understand or experiment
with the code, nor did I run the regression tests.

  Problem is that this code doesn't show up in regression tests because
they use a different set of routines (htmlNodeDumpOutput i.e. saving to
an I/O buffer not to a memory buffer ... some cleanup might be needed :-\).

  I have cleaned up htmlNodeDump(), considering that htmlNodeDumpOutput()
is the tested routine and that its output is correct.

  I commited the change to CVS, patch enclosed

Daniel

-- 
Daniel Veillard      | Red Hat Network http://redhat.com/products/network/
veillard redhat com  | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/

Attachment: htmldump.diff
Description: Text document



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]