[ http://issues.apache.org/jira/browse/XALANJ-2330?page=comments#action_12445687 ] Ellis Pritchard commented on XALANJ-2330: -----------------------------------------
Should startDTD() also set m_needToOutputDocTypeDecl to false? > ToXMLSAXHandler generates startDTD event, but not corresponding endDTD event > ---------------------------------------------------------------------------- > > Key: XALANJ-2330 > URL: http://issues.apache.org/jira/browse/XALANJ-2330 > Project: XalanJ2 > Issue Type: Bug > Components: Serialization > Affects Versions: 2.7 > Environment: Solaris 10, Java 1.4, Xerces 2.8.0, Xalan 2.7.0 > Reporter: Ellis Pritchard > Attachments: jira2330.patch1.txt > > > 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) > { > String doctypePublic = getDoctypePublic(); > if (doctypeSystem != null) > m_lexHandler.startDTD( > name, > doctypePublic, > doctypeSystem); > } > 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. -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
