List of usage examples for org.dom4j DocumentType setPublicID
void setPublicID(String publicID);
From source file:com.cladonia.xml.XMLUtilities.java
License:Open Source License
/** * Sets the XML DOCTYPE//from w w w .ja va 2 s . c o m * * @param document The Exchanger document * @param name The DOCTYPE name (should be root element's name) * @param type The type (SYSTEM,PUBLIC or INTERNAL) * @param publicID The publicID * @param systemID The systemID * */ public static void setXMLDoctype(ExchangerDocument document, String name, String type, String publicID, String systemID) { XDocument xdoc = document.getDocument(); DocumentType dt = xdoc.getDocType(); if (dt != null) { // update existing Doctype dt.setElementName(name); if (type.equals(INTERNAL)) { dt.setPublicID(null); dt.setSystemID(null); } else if (type.equals(SYSTEM)) { dt.setPublicID(null); dt.setSystemID(systemID); } else { dt.setPublicID(publicID); dt.setSystemID(systemID); } } else { // add new doctype if (type.equals(INTERNAL)) { xdoc.addDocType(name, null, null); } else if (type.equals(SYSTEM)) { xdoc.addDocType(name, null, systemID); } else { xdoc.addDocType(name, publicID, systemID); } } }