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); }
/** * 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; }
case Node.DOCUMENT_TYPE_NODE: DocumentType dt = (DocumentType) node; writer.write ("<!DOCTYPE " + dt.getName ()); String systemID = dt.getSystemId (); if (systemID != null) {
orig.getDocumentElement().getTagName(), 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()); } }
pOut.print(pDoctype.getName());
/** * 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; }
document.addDocType(domDocType.getName(), domDocType .getPublicId(), domDocType.getSystemId());
public String getDTDRootName() { if (mCurrEvent == DTD) { return ((DocumentType) mCurrNode).getName(); } return null; }
public String getDTDRootName() { if (mCurrEvent == DTD) { return ((DocumentType) mCurrNode).getName(); } return null; }
public String getDTDRootName() { if (mCurrEvent == DTD) { return ((DocumentType) mCurrNode).getName(); } return null; }
protected static String getDocumentTypeData(DocumentType doctype) { String data = doctype.getName(); if (doctype.getPublicId() != null) { data += " PUBLIC \"" + doctype.getPublicId() + "\""; String systemId = doctype.getSystemId(); if (systemId == null) systemId = ""; data += " \"" + systemId + "\""; } else data += " SYSTEM \"" + doctype.getSystemId() + "\""; return data; }
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()); } }
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()); } } }
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()); } } }
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 validateDocument(Document document) throws SAXException, IOException { DocumentType docType = document.getDoctype(); if (docType != null) { String documentDtd = docType.getSystemId(); String rootElement = docType.getName(); String expectedDtd = (String)this.dtds.get(rootElement); if (!compareDtd(expectedDtd, documentDtd)) throw new SAXException("The dtd " + documentDtd + " does not match the dtd expected from the specification"); } }
private void _writeDocumentType (@Nonnull final XMLEmitter aXMLWriter, @Nonnull final DocumentType aDocType) { if (m_aSettings.getSerializeDocType ().isEmit ()) aXMLWriter.onDocumentType (aDocType.getName (), aDocType.getPublicId (), aDocType.getSystemId ()); }
protected void runTest() throws Throwable { Document document = dbf.newDocumentBuilder().parse(TestWithParser1.class.getResource("test1.xml").toString()); DocumentType doctype = document.getDoctype(); assertEquals("root", doctype.getName()); assertNull(doctype.getPublicId()); assertNull(doctype.getSystemId()); assertEquals("<!ELEMENT root (#PCDATA)>", doctype.getInternalSubset().trim()); } }
protected void runTest() throws Throwable { Document document = dbf.newDocumentBuilder().parse(TestWithParser2.class.getResource("test2.xml").toString()); DocumentType doctype = document.getDoctype(); assertEquals("root", doctype.getName()); assertEquals("dummy", doctype.getPublicId()); assertEquals("test.dtd", doctype.getSystemId()); assertNull(doctype.getInternalSubset()); } }