I'm having some problems with the
http://apache.org/xml/properties/dom/document-class-name property of the DOM
parser.
Actually, when I set it to my own document implementation, which is an empty
wrapper
around the default one, the documents do not have a document type. The parsing
seems
however to be done correctly. Is it a bug in the default DocumentImpl
implementation
?
Sebastien
Here is the code I use :
import org.apache.xerces.dom.*;
import org.apache.xerces.parsers.*;
public class Test2 {
public static void main (String[] args) {
DOMParser parser = new DOMParser();
try {
parser.setProperty("http://apache.org/xml/properties/dom/document-class-name",
"MyDocumentImpl");
} catch (org.xml.sax.SAXNotSupportedException e) {
} catch (org.xml.sax.SAXNotRecognizedException e) {
}
try {
parser.parse("File:///home/sponce/mycmt/Det/XmlEditor/v3d1/src/Test2.xml");
} catch (java.io.IOException e) {
} catch (org.xml.sax.SAXException e) {
}
Document document = parser.getDocument();
DocumentType documentType = document.getDoctype();
System.out.println(documentType);
}
}
The MyDocumentImpl class :
import org.apache.xerces.dom.*;
import org.w3c.dom.*;
public class MyDocumentImpl extends DocumentImpl {
public MyDocumentImpl() {
super();
}
public MyDocumentImpl(boolean grammarAccess) {
super(grammarAccess);
}
public MyDocumentImpl(DocumentType doctype) {
super(doctype);
}
public MyDocumentImpl(DocumentType doctype, boolean grammarAccess) {
super(doctype, grammarAccess);
}
}
And the xml file I use for testing :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE DDDB SYSTEM "DTD/structure.dtd">
<DDDB>
</DDDB>