public void replaceDocumentType(String docTypeName, String publicId, String systemId) { if (document == null) return; DocumentTypeImpl docType = (DocumentTypeImpl) document.getDoctype(); if (docType == null) return; if (publicId == null && systemId == null) document.removeChild(docType); else { docType.setPublicId(publicId); docType.setSystemId(systemId); } }
/** * Creates an empty <code>DocumentType</code> node. Entity declarations * and notations are not made available. Entity reference expansions and * default attribute additions do not occur. It is expected that a future * version of the DOM will provide a way for populating a * <code>DocumentType</code>.<br> * HTML-only DOM implementations do not need to implement this method. * * @param qualifiedNameThe * qualified name of the document type to be created. * @param publicIdThe * external subset public identifier. * @param systemIdThe * external subset system identifier. * @return A new <code>DocumentType</code> node with * <code>Node.ownerDocument</code> set to <code>null</code>. * @exception DOMException * INVALID_CHARACTER_ERR: Raised if the specified qualified * name contains an illegal character. <br> * NAMESPACE_ERR: Raised if the <code>qualifiedName</code> * is malformed. * @see DOM Level 2 */ public DocumentType createDocumentType(String qualifiedName, String publicId, String systemId) throws DOMException { DocumentTypeImpl documentType = new DocumentTypeImpl(); documentType.setName(qualifiedName); documentType.setPublicId(publicId); documentType.setSystemId(systemId); return documentType; }
return; if (publicId != null) docType.setPublicId(publicId); if (systemId != null) docType.setSystemId(systemId);