private void writeDocumentType(DocumentType docType, Writer writer, int depth) throws IOException { String publicId = docType.getPublicId(); String internalSubset = docType.getInternalSubset(); for (int i = 0; i < depth; ++i) { writer.append(' '); } writer.append("<!DOCTYPE ").append(docType.getName()); if (publicId != null) { writer.append(" PUBLIC '").append(publicId).append("' "); } else { writer.write(" SYSTEM "); } writer.append("'").append(docType.getSystemId()).append("'"); if (internalSubset != null) { writer.append(" [").append(internalSubset).append("]"); } writer.append('>').append(lineSeparator); }
/** * Return the public identifier of the external subset, * normalized as described in 4.2.2 External Entities [XML]. If there is * no external subset or if it has no public identifier, this property * has no value. * * @return the public identifier String object, or null if there is none. */ public String getDocumentTypeDeclarationPublicIdentifier() { Document doc; if (m_root.getNodeType() == Node.DOCUMENT_NODE) doc = (Document) m_root; else doc = m_root.getOwnerDocument(); if (null != doc) { DocumentType dtd = doc.getDoctype(); if (null != dtd) { return dtd.getPublicId(); } } return null; }
private void streamXML(final Document doc, final OutputStream out) { try {// Use a Transformer for output final TransformerFactory tFactory = TransformerFactory.newInstance(); final Transformer transformer = tFactory.newTransformer(); if (doc.getDoctype() != null) { final String systemId = doc.getDoctype().getSystemId(); final String publicId = doc.getDoctype().getPublicId(); transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, publicId); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, systemId); } transformer.setOutputProperty(OutputKeys.INDENT, "yes"); transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); final DOMSource source = new DOMSource(doc); final StreamResult result = new StreamResult(out); transformer.transform(source, result); } catch (final Exception e) { e.printStackTrace(); } }
/** * Return the public identifier of the external subset, * normalized as described in 4.2.2 External Entities [XML]. If there is * no external subset or if it has no public identifier, this property * has no value. * * @return the public identifier String object, or null if there is none. */ public String getDocumentTypeDeclarationPublicIdentifier() { Document doc; if (m_root.getNodeType() == Node.DOCUMENT_NODE) doc = (Document) m_root; else doc = m_root.getOwnerDocument(); if (null != doc) { DocumentType dtd = doc.getDoctype(); if (null != dtd) { return dtd.getPublicId(); } } return null; }
DocumentType dt = doc2.getDoctype(); if (dt != null) { String pub = dt.getPublicId(); if (pub != null) { t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, pub);
buf.append("<!DOCTYPE ").append(n.getNodeName()); DocumentType dt = (DocumentType) n; if (dt.getPublicId() != null) { buf.append(" PUBLIC \"").append(dt.getPublicId()).append('"');
String publicId = node.getPublicId(); String systemId = node.getSystemId(); String internalSubset = node.getInternalSubset();
String systemID = dt.getSystemId (); if (systemID != null) { String publicID = dt.getPublicId (); if (publicID != null) { writer.write (" PUBLIC '" + publicID + "' '");
String publicId = node.getPublicId(); String systemId = node.getSystemId(); String internalSubset = node.getInternalSubset();
buf.append("<!DOCTYPE ").append(n.getNodeName()); DocumentType dt = (DocumentType) n; if (dt.getPublicId() != null) { buf.append(" PUBLIC \"").append(dt.getPublicId()).append('"');
DocumentType doctype = (DocumentType) node; if ("publicId".equals(localName)) { result.add(createAttribute(doctype, "publicId", doctype.getPublicId())); } else if ("systemId".equals(localName)) { result.add(createAttribute(doctype, "systemId", doctype.getSystemId()));
builder.getDOMImplementation().createDocumentType( orig.getDoctype().getName(), orig.getDoctype().getPublicId(), orig.getDoctype().getSystemId()));
protected DOMDocumentType asDocumentType(org.w3c.dom.DocumentType docType) { if (docType instanceof DOMDocumentType) { return (DOMDocumentType) docType; } else { return new DOMDocumentType(docType.getName(), docType.getPublicId(), docType.getSystemId()); } }
transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId()); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId());
pOut.print(pDoctype.getName()); String publicId = pDoctype.getPublicId(); if (!StringUtil.isEmpty(publicId)) { pOut.print(" PUBLIC ");
= (org.w3c.dom.DocumentType) node; document.addDocType(domDocType.getName(), domDocType .getPublicId(), domDocType.getSystemId());
/** * This will build a JDOM Element from an existing DOM Element * * @param doctype <code> org.w3c.dom.Element</code> object * @return <code>Element</code> - JDOM Element object * @since JDOM2 */ public org.jdom2.DocType build(org.w3c.dom.DocumentType doctype) { String publicID = doctype.getPublicId(); String systemID = doctype.getSystemId(); String internalDTD = doctype.getInternalSubset(); DocType docType = factory.docType(doctype.getName()); docType.setPublicID(publicID); docType.setSystemID(systemID); docType.setInternalSubset(internalDTD); return docType; }
if (srcDoc.getDoctype() != null) pubID = srcDoc.getDoctype().getPublicId(); sysID = srcDoc.getDoctype().getSystemId();
protected DOMDocumentType asDocumentType(org.w3c.dom.DocumentType docType) { if (docType instanceof DOMDocumentType) { return (DOMDocumentType) docType; } else { return new DOMDocumentType(docType.getName(), docType.getPublicId(), docType.getSystemId()); } }
private void _writeDocumentType (@Nonnull final XMLEmitter aXMLWriter, @Nonnull final DocumentType aDocType) { if (m_aSettings.getSerializeDocType ().isEmit ()) aXMLWriter.onDocumentType (aDocType.getName (), aDocType.getPublicId (), aDocType.getSystemId ()); }