Vadim Gritsenko <[EMAIL PROTECTED]> wrote: >> > >> The work around seems to be to wrap the text with pseudo XML eg: > >> > >> <hack> > >> Generated text > >> </hack> > > > > > > That is a common requirement for XML parsers. > > > >> > >> But I believe this shouldn't be necessary? Strangely enough when I > >> do this, > >> the "hack" elements are not output and everything works > fine. Anyone > >> have > >> any ideas where the problem might lie? > > > > Related: http://nagoya.apache.org/bugzilla/show_bug.cgi?id=10242 >
Hmm, I didn't find that when searching the archives; could have save me half a day (sigh).... I sort have to agree, there needs to be some debug level indication of this. Thinking out loud here: couldn't TextSerializer check if startDocument has been called before the first instance of character and if not call startDocument? This would make things both backward compatible with people who are currently wrapping the text with XML and work as expected for those of us porting text production into Cocoon for the first time. private hasWrapperElement = false; public void characters(char c[], int start, int len) throws SAXException { if (!hasWrapperElement) { // Maybe log something here? startElement( "hack",... ); } super.characters(...); if (!hasWrapperElement) { endElement( "hack",... ); hasWrapperElement = true; } } public void startElement(String eltUri, String eltLocalName, String eltQName, Attributes attrs) throws SAXException { hasWrapperElement = true; super.startElement(...); } Yuck, but ???