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); }
/** * A document type declaration information item has the following properties: * * 1. [system identifier] The system identifier of the external subset, if * it exists. Otherwise this property has no value. * * @return the system identifier String object, or null if there is none. */ public String getDocumentTypeDeclarationSystemIdentifier() { 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.getSystemId(); } } 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(); } }
/** * A document type declaration information item has the following properties: * * 1. [system identifier] The system identifier of the external subset, if * it exists. Otherwise this property has no value. * * @return the system identifier String object, or null if there is none. */ public String getDocumentTypeDeclarationSystemIdentifier() { 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.getSystemId(); } } return null; }
t.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, pub); String sys = dt.getSystemId(); if (sys != null) { t.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, sys);
buf.append(" PUBLIC \"").append(dt.getPublicId()).append('"'); if (dt.getSystemId() != null) { buf.append('"').append(dt.getSystemId()).append('"');
String systemId = node.getSystemId(); String internalSubset = node.getInternalSubset();
DocumentType dt = (DocumentType) node; writer.write ("<!DOCTYPE " + dt.getName ()); String systemID = dt.getSystemId (); if (systemID != null) { String publicID = dt.getPublicId ();
String systemId = node.getSystemId(); String internalSubset = node.getInternalSubset();
buf.append(" PUBLIC \"").append(dt.getPublicId()).append('"'); if (dt.getSystemId() != null) { buf.append(" \"").append(dt.getSystemId()).append('"');
result.add(createAttribute(doctype, "publicId", doctype.getPublicId())); } else if ("systemId".equals(localName)) { result.add(createAttribute(doctype, "systemId", doctype.getSystemId())); } else if ("elementName".equals(localName)) { result.add(createAttribute(doctype, "elementName", doctype.getNodeName()));
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()); } }
if (doctype != null) { transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, doctype.getPublicId()); transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, doctype.getSystemId());
String systemId = pDoctype.getSystemId(); if (!StringUtil.isEmpty(systemId)) { if (StringUtil.isEmpty(publicId)) {
= (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; }
sysID = srcDoc.getDoctype().getSystemId();
public String getDTDSystemId() { if (mCurrEvent == DTD) { return ((DocumentType) mCurrNode).getSystemId(); } return null; }
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()); } }