if (target != null && target.equals("xml")) { //$NON-NLS-1$
pi = (ProcessingInstruction) child;
child = child.getNextSibling();
}
}
IDOMDocumentType docType = (IDOMDocumentType) document.getDoctype();
if (declaration != null) {
if (pi != null) {
pi.setData(declaration);
}
else {
pi = document.createProcessingInstruction("xml", declaration); //$NON-NLS-1$
document.insertBefore(pi, child);
insertBreak(model, child);
}
}
if (publicId != null) {
HTMLDocumentTypeEntry entry = HTMLDocumentTypeRegistry.getInstance().getEntry(publicId);
String name = (entry != null ? entry.getName() : null);
if (name == null || name.length() == 0)
name = "HTML"; // default //$NON-NLS-1$
if (docType != null) {
if (!name.equals(docType.getName())) { // replace
Node parent = docType.getParentNode();
child = docType;
docType = (IDOMDocumentType) document.createDoctype(name);
parent.insertBefore(docType, child);
parent.removeChild(child);
}
}
else {
docType = (IDOMDocumentType) document.createDoctype(name);
document.insertBefore(docType, child);
insertBreak(model, child);
}
docType.setPublicId(publicId);
if (entry != null) {
String systemId = entry.getSystemId();
if (systemId != null)
docType.setSystemId(systemId);
String namespaceURI = entry.getNamespaceURI();
if (namespaceURI != null) {
Element element = document.getDocumentElement();
if (element != null) {
element.setAttribute("xmlns", namespaceURI); //$NON-NLS-1$