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=11206>.
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=11206

Parser looses information when setting setCreateEntityReferenceNodes(false)





------- Additional Comments From [EMAIL PROTECTED]  2002-07-26 14:03 -------
Hallo!

I think, that the problem isn't in the code, because it did work with Xerces 
2.0.1

I use following methods:

Parser:


public class XHTMLParser extends AbstractDOMParser {
public XHTMLParser(ErrorHandler errorHandler) throws Exception {
        super();
        setErrorHandler(errorHandler);
        initialize(); 
}
private void initialize() throws Exception {
        setCreateEntityReferenceNodes(true);
        setIncludeIgnorableWhitespace(true);
        setLoadDTDGrammar(true);
        setLoadExternalDTD(true);
        setNamespaces(true);
        setNormalizeAttributeValues(false);
        setValidation(false);
}
}

Parsing the document:


public void initializeAndStartDomParser() throws Exception {
        ErrorHandler errorHandler = new ErrorHandler() {
                public void error(SAXParseException e) {
                        System.out.println("Error: " + e.getMessage());
                }
                public void fatalError(SAXParseException e) {
                        System.out.println("Fatal Error: " + e.getMessage());
                }
                public void warning(SAXParseException e) throws SAXException {
                        System.out.println("Warning: " + e.getMessage());
                }
        };
        XHTMLParser parser = new XHTMLParser(errorHandler);
        FileInputStream fis = new FileInputStream(getTempDir() 
+ "/parsedForCDATA.htm");
        InputSource is = new InputSource(fis);
        is.setSystemId(importer.getSystemId());
        parser.setFeature("http://apache.org/xml/features/create-cdata-nodes";, 
false);
        parser.parse(is);
        rootDocument = parser.getDocument();
        writeTestDoc(rootDocument);
}       

Serializing the document:


public void writeTestDoc(Document aDocument) throws Exception{
        OutputStream o = new FileOutputStream(importer.getTempDir() 
+ "/TestDoc.txt");
        OutputStreamWriter w = new OutputStreamWriter(o);
        OutputFormat oF = new OutputFormat( Method.XML, null, false);
        oF.setOmitDocumentType(true);
        XMLSerializer s = new XMLSerializer(oF);
        s.setOutputCharStream(w);
        s.serialize(aDocument);
        o.close();
}

Best regards
Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to