DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23648>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=23648

HTMLGenerator produces NullPointerException  on HML-docs with   XML-Declaration

[EMAIL PROTECTED] changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |CLOSED



------- Additional Comments From [EMAIL PROTECTED]  2003-10-29 16:04 -------
sorry for answering so late: I was on holidays.


I tested it and it works fine, but to avoide code duplication
I would prevere:

<new-code>
DOMStreamer domStreamer = new DOMStreamer(this.contentHandler,this.lexicalHandler);
contentHandler.startDocument();
if(xpath != null) {
        NodeList nl = processor.selectNodeList(doc, xpath);
        int length = nl.getLength();
        for(int i=0;i<length;i++) {
                domStreamer.stream(nl.item(i));
        }
} else {
        // If the HTML document contained a <?xml ... declaration, tidy would have
recognized
        // this as a processing instruction (with a 'null' target), giving problems 
further
        // on in the pipeline. Therefore we only serialize the document element.
        domStreamer.stream(doc.getDocumentElement());
}
contentHandler.endDocument();
</new-code>

to the old version:
<old-code>
if(xpath != null) {
        DOMStreamer domStreamer = new 
DOMStreamer(this.contentHandler,this.lexicalHandler);

        contentHandler.startDocument();
        NodeList nl = processor.selectNodeList(doc, xpath);
        int length = nl.getLength();
        for(int i=0;i<length;i++) {
                domStreamer.stream(nl.item(i));
        }
        contentHandler.endDocument();
} else {
        DOMStreamer streamer = new 
DOMStreamer(this.contentHandler,this.lexicalHandler);
        // If the HTML document contained a <?xml ... declaration, tidy would have
recognized
        // this as a processing instruction (with a 'null' target), giving problems 
further
        // on in the pipeline. Therefore we only serialize the document element.
        this.contentHandler.startDocument();
        streamer.stream(doc.getDocumentElement());
        this.contentHandler.endDocument();
}
</old-code>

Reply via email to