@Override Object getDocumentType(Object node) { return node instanceof Document ? ((Document) node).getDoctype() : 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; }
/** * 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; }
/** * Check if file is an SVG * @param f * @return */ public static boolean isSVGImage(File f){ try { System.out.println("Checking if " + f.getAbsolutePath() + " is an SVG file..."); Document document = getXMLDocumentFromFile(f); boolean headerSVG = document.getDoctype() != null && document.getDoctype().getName().toLowerCase().equals("svg"); if(headerSVG) return true; else{ return document.getElementsByTagName("svg") != null; } } catch (Exception e) {} return false; }
/** * 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; }
/** * 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 String unexpandEntities(Node n, String te, boolean withQuotes) { String result = te; DocumentType doctype = n.getOwnerDocument().getDoctype();
Transformer t = tf.newTransformer( new StreamSource(new StringReader(IDENTITY_XSLT_WITH_INDENT))); DocumentType dt = doc2.getDoctype(); if (dt != null) { String pub = dt.getPublicId();
orig.getDocumentElement().getTagName(), builder.getDOMImplementation().createDocumentType( orig.getDoctype().getName(), orig.getDoctype().getPublicId(), orig.getDoctype().getSystemId()));
if (null != document.getDoctype()) { Node root = document.getDocumentElement(); Document copiedDocument = getDocumentBuilder().newDocument();
DocumentType doctype = doc.getDoctype();
DocumentType doctype = doc.getDoctype();
DocumentType doctype = doc.getDoctype();
DocumentType doctype = _document.getDoctype(); if (doctype != null) { NamedNodeMap entities = doctype.getEntities();
DocumentType doctype = doc.getDoctype();
DocumentType docType = node.getOwnerDocument().getDoctype(); if (docType != null) { NamedNodeMap entities = docType.getEntities();
DocumentType docType = node.getOwnerDocument().getDoctype(); if (docType != null) { NamedNodeMap entities = docType.getEntities();
/** * This converts the JDOM <code>DocType</code> parameter to a DOM DocumentType, * returning the DOM version. The DOM implementation is the one supplied by * the current DOMAdapter. * <p> * Unlike the other DOM Nodes, you cannot use a DOM Document to simply create a DOM DocumentType Node, * it has to be created at the same time as the DOM Document instance. As a result, there is no * version of this method that takes a DOM Document instance. * * @param doctype * <code>DocType</code> to output. * @return an <code>org.w3c.dom.DocumentType</code> version * @throws JDOMException * if output failed. * @since JDOM2 */ public org.w3c.dom.DocumentType output(DocType doctype) throws JDOMException { return adapter.createDocument(doctype).getDoctype(); }
if (srcDoc.getDoctype() != null) pubID = srcDoc.getDoctype().getPublicId(); sysID = srcDoc.getDoctype().getSystemId();