Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.7
-
None
-
None
-
Solaris 10, Java 1.4, Xerces 2.8.0, Xalan 2.7.0
-
PatchAvailable
Description
The org.apache.xml.serializer.ToXMLSAXHandler generates a startDTD() event on the LexicalHandler for the first element of the document (lines 648-662) to ensure that the document type gets set, however, it doesn't then generate a corresponding endDTD() event after doing so, which leaves the 'state' indeterminate, and behavior relying on the startDTD()/endDTD() pair will break.
// Handle document type declaration (for first element only)
if (m_needToOutputDocTypeDecl)
{
String doctypeSystem = getDoctypeSystem();
if (doctypeSystem != null && m_lexHandler != null)
m_needToOutputDocTypeDecl = false;
}
As a critical example, org.apache.xml.dtm.ref.sax2dtm.SAX2DTM sets a flag, m_insideDTD to true on startDTD() and false on endDTD(); if the flag is true, comments are ommitted from the output (line 2446); if the flag is left hanging by this issue, all comments in the document will be omitted.
This is a critical problem if you are trying to do something with the comments, such as traditional SSI.
The fix would be to add an endDTD() event immediately after the startDTD() event in ToXMLSAXHandler#startElement(String,String,String,Attributes).
I'm not sure if this also effects other handlers.