}
serializeElement( (Element) node );
break;
}
case Node.DOCUMENT_NODE : {
DocumentType docType;
DOMImplementation domImpl;
NamedNodeMap map;
Entity entity;
Notation notation;
int i;
serializeDocument();
// If there is a document type, use the SAX events to
// serialize it.
docType = ( (Document) node ).getDoctype();
if (docType != null) {
// DOM Level 2 (or higher)
domImpl = ( (Document) node ).getImplementation();
try {
String internal;
_printer.enterDTD();
_docTypePublicId = docType.getPublicId();
_docTypeSystemId = docType.getSystemId();
internal = docType.getInternalSubset();
if ( internal != null && internal.length() > 0 )
_printer.printText( internal );
endDTD();
}
// DOM Level 1 -- does implementation have methods?
catch (NoSuchMethodError nsme) {
Class docTypeClass = docType.getClass();
String docTypePublicId = null;
String docTypeSystemId = null;
try {
java.lang.reflect.Method getPublicId = docTypeClass.getMethod("getPublicId", (Class[]) null);
if (getPublicId.getReturnType().equals(String.class)) {
docTypePublicId = (String)getPublicId.invoke(docType, (Object[]) null);
}
}
catch (Exception e) {
// ignore
}
try {
java.lang.reflect.Method getSystemId = docTypeClass.getMethod("getSystemId", (Class[]) null);
if (getSystemId.getReturnType().equals(String.class)) {
docTypeSystemId = (String)getSystemId.invoke(docType, (Object[]) null);
}
}
catch (Exception e) {
// ignore
}
_printer.enterDTD();
_docTypePublicId = docTypePublicId;
_docTypeSystemId = docTypeSystemId;
endDTD();
}
serializeDTD(docType.getName());
}
_started = true;
// !! Fall through