Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Labels:None
-
Number of attachments :
Description
When used after writeEmptyElement, writeEndElement omits the close tag of the previous element, producing invalid xml.
Since: SVN Rev. 53, 2005-08-31
Steps to reproduce:
writeStartElement("start"); writeEmptyElement("empty"); writeEndElement();
Result: <start><empty/>
Workaround:
writeStartElement("start"); writeEmptyElement("empty"); writeCharacters(""); // closes empty tag writeEndElement();
Result: <start><empty/></start>
Fix:
--- old\XMLWriterBase.java 2006-01-21 00:25:20.641329600 +0100 +++ new\XMLWriterBase.java 2006-01-21 00:39:27.799483200 +0100 @@ -406,8 +406,9 @@ public void writeEndElement() throws XMLStreamException { - //boolean wasEmpty = startElementOpened; - boolean wasEmpty = isEmpty = isOpen(); + // shortcut close tag, except if opened with writeEmptyElement + boolean wasEmpty = !isEmpty && isOpen(); + isEmpty = isOpen(); closeStartElement(); String prefix = (String) prefixStack.pop(); String local = (String) localNameStack.pop();
I actually think I fixed this yesterday, before seeing this bug report. Seems to work, to the degree that the matching simple writer test passes.