Hi Mats
 
A quick question - is there any reason why you can't use SAXReader to load your document? Is it something to do with Cocoon2 why you're trying to use SAXContentHandler directly?
 
If you want to use SAXContentHandler directly, I'd take a look at the code of SAXReader, in particular the configureReader() method. The SAXContentHandler also implements the LexicalHandler API from SAX which is used to get notified of comments.
----- Original Message -----
Sent: Wednesday, June 27, 2001 9:39 AM
Subject: [dom4j-dev] Is there a bug in the SAXContentHandler or the SAXWriter?

Hi,
 
Is there a bug in the SAXContentHandler or the SAXWriter?
 
I wanted to use the DOM4J in my Cocoon2 app and built a simple DOM4JAbstractTransformer, which uses the SAXContenthandler to build a document which is then left to the user to do whatever he/she want to.
After that I use the SAXWriter to send the events down a SAX pipeline..
 
My SimpleTransformer extends the DOM4JAbstractTransformer and does nothing! with the document.

The source XML looks like this:
 
<?xml version="1.0" encoding="iso-8859-1"?>
    <page xmlns:page="http://www.spectral.se/datawise/30" xmlns:xform="http://www.w3.org/2001/06/xforms" xml:lang="sv">
        <!-- model + instance for a component -->
        <xform:xform id="search" href="http://">
        <xform:submitInfo id="ID" target="http://www.spectral.se/raa/page" method="..."/>
        <!-- THE MODEL PART NOT IMPLEMENTED  -->
        <xform:model id="" type="" href=""/>
        <xform:instance id="" href="">
            ...
             ...
 
I´m using the SAXContenHandler to build the document.

The class DOM4JBuilder I´ve built extends SAXContentHandler and overrides the endDocument function to notify another method that the document is parsed and that its available for processing.
 
public void endDocument() {
    super.endDocument();
    this.notify(this.contentHandler.getDocument());
}
 
I don´t do anything to the document before writing to the logContenthandler.

Question:
1. Where did the comment go?
2. Where did the startPrefixMapping come from?
3. Or is it simply my source XML that is to blame? :-)
 
1. You're probably not registering SAXContentHandler as the LexicalHandler for the SAX XMLReader
2. startPrefixMapping is a namespace thing - e.g. xmlns:page="..." is the start of a prefix mapping.
3. Not at all :-)
 
James

Reply via email to