Doctype added twice when ignorableWhitespace() is called before startDocument()
-------------------------------------------------------------------------------
Key: XALANJ-2369
URL: https://issues.apache.org/jira/browse/XALANJ-2369
Project: XalanJ2
Issue Type: Bug
Components: Serialization
Affects Versions: 2.7
Environment: Windows, Mac OS X, Linux
Reporter: Alexander Klimetschek
In some cases the Doctype gets added twice. I experienced it when serializing
as HTML, but from looking at the code I see the problem is generic for
serialization.
Steps to reproduce:
Since using Cocoon, I cannot provide a clean java snippet that reproduces the
failure. The setup is a TransformerHandler writing into a StreamResult with
output properties set to method=html (apart others):
TransformerHandler handler = this.getTransformerHandler();
handler.getTransformer().setOutputProperties(this.format);
handler.setResult(new StreamResult(this.output));
this.setContentHandler(handler);
this.setLexicalHandler(handler);
First call:
The stacktrace upon the first call is when ToHTMLStream.ignorableWhiteSpace()
is called, which effectively calls startDocumentInternal() that writes out the
doctype for the first time. The m_needToCallStartDocument is set to false.
Second call:
The TransformerIdentityImpl.flushStartDoc() calls ToHTMLStream.startDocument(),
which calls startDocumentInternal() *without* checking if
m_needToCallStartDocument is true or not. The doctype is added for the second
time.
Proposed fix:
SerializerBase.startDocument() should call startDocumentInternal() only if
m_needToCallStartDocument is true. Or, even better, include the check for
m_needToCallStartDocument inside startDocumentInternal() method to prevent
similar mistakes.
Maybe related to http://issues.apache.org/jira/browse/XALANJ-1685 ??
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]