On Wed, 2 Jan 2002, Torsten Curdt wrote:
>
> Be careful. The above will break the XSP SAX structure.
> You need to think of the events:
>
> -xsp:startDocument
> -xsp:startElement
> -xsp:endElement
> - ... some more ...
> // now your code
> -parser:startDocument
> -xsp:startElement
> -xsp:endElement
> - ... some more ...
> -parser:endDocument
> -xsp:endDocument
>
> You see?! start/end Document will be called twice.
> This is illegal! Wrapp the page ContentHandler
> inside a org.apache.cocoon.xml.EmbeddedXMLPipe before
> passing it to the parser.
> --
> Torsten
Thanks Torsten,
That was ideed the problem I had. I only wonder how i should have found
this solution with only the current C2 docs, but at least there is docu.
The complete code snippet should that works is:
Parser parser = null;
try {
org.xml.sax.InputSource inputSource = new
org.xml.sax.InputSource(
new StringReader(xmldata)
);
this.getLogger().debug("Looking up parser");
parser = (Parser)this.manager.lookup(Parser.ROLE);
parser.setContentHandler(new
EmbeddedXMLPipe(this.contentHandler));
parser.setLexicalHandler(this.lexicalHandler);
parser.parse(inputSource);
} catch (Exception ex) {
ex.printStackTrace();
this.getLogger().debug(ex.getMessage());
} finally {
if (parser != null) {
this.getLogger().debug("Releasing parser");
this.manager.release((Component)parser);
}
}
Anton Jansen
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <[EMAIL PROTECTED]>
For additional commands, e-mail: <[EMAIL PROTECTED]>