protected void entityResolver(Document document) throws SAXException { if (entityResolver != null) { DocumentType docType = document.getDocType(); if (docType != null) { String publicID = docType.getPublicID(); String systemID = docType.getSystemID(); if ((publicID != null) || (systemID != null)) { try { entityResolver.resolveEntity(publicID, systemID); } catch (IOException e) { throw new SAXException("Could not resolve publicID: " + publicID + " systemID: " + systemID, e); } } } } }
public int compare(DocumentType o1, DocumentType o2) { if (o1 == o2) { return 0; } else if (o1 == null) { // null is less return -1; } else if (o2 == null) { return 1; } int answer = compare(o1.getPublicID(), o2.getPublicID()); if (answer == 0) { answer = compare(o1.getSystemID(), o2.getSystemID()); if (answer == 0) { answer = compare(o1.getName(), o2.getName()); } } return answer; }
public void endDTD() throws SAXException { insideDTDSection = false; DocumentType docType = getDocument().getDocType(); if (docType != null) { if (internalDTDDeclarations != null) { docType.setInternalDeclarations(internalDTDDeclarations); } if (externalDTDDeclarations != null) { docType.setExternalDeclarations(externalDTDDeclarations); } } internalDTDDeclarations = null; externalDTDDeclarations = null; }
DocumentType doctype = (DocumentType) node; if ("publicId".equals(localName)) { result.add(new DefaultAttribute("publicId", doctype.getPublicID())); } else if ("systemId".equals(localName)) { result.add(new DefaultAttribute("systemId", doctype.getSystemID())); } else if ("elementName".equals(localName)) { result.add(new DefaultAttribute("elementName", doctype.getElementName()));
protected void writeDocType(DocumentType docType) throws IOException { if (docType != null) { docType.write( writer ); //writeDocType( docType.getElementName(), docType.getPublicID(), docType.getSystemID() ); writePrintln(); } }
public String getPublicId() { return docType.getPublicID(); }
public String getSystemId() { return docType.getSystemID(); }
/** * Test verifies correct identification of the internal DTD subset and * correct non-presence of the external DTD subset. * * @throws Exception * DOCUMENT ME! */ public void testInternalDTDSubset() throws Exception { /* * Setup the expected DocumentType. * * @todo dom4j should expose a DefaultDocumentType constructor that * accepts only the elementName property. This is used when only an * internal DTD subset is being provided via the <!DOCTYPE foo [...]> * syntax, in which case there is neither a SYSTEM nor PUBLIC * identifier. */ DocumentType expected = new DefaultDocumentType(); expected.setElementName("greeting"); expected.setInternalDeclarations(getInternalDeclarations()); /* * Parse the test XML document and compare the expected and actual * DOCTYPEs. */ assertSameDocumentType(expected, readDocument(XML_INTERNAL_FILE, true, false).getDocType()); }
/** * Test verifies correct identification of the external DTD subset and * correct non-presence of the internal DTD subset. */ public void testExternalDTDSubset() throws Exception { /* * Setup the expected DocumentType. */ DocumentType expected = new DefaultDocumentType("another-greeting", null, DTD_SYSTEM_ID); expected.setExternalDeclarations(getExternalDeclarations()); /* * Parse the test XML document and compare the expected and actual * DOCTYPEs. */ assertSameDocumentType(expected, readDocument(XML_EXTERNAL_FILE, false, true).getDocType()); }
public String getName() { return docType.getElementName(); }
DocumentType doctype = (DocumentType) node; if ("publicId".equals(localName)) { result.add(new DefaultAttribute("publicId", doctype.getPublicID())); } else if ("systemId".equals(localName)) { result.add(new DefaultAttribute("systemId", doctype.getSystemID())); } else if ("elementName".equals(localName)) { result.add(new DefaultAttribute("elementName", doctype.getElementName()));
protected void writeDocType(DocumentType docType) throws IOException { if (docType != null) { docType.write(writer); writePrintln(); } }
publicID = docType.getPublicID(); systemID = docType.getSystemID();
public int compare(DocumentType o1, DocumentType o2) { if (o1 == o2) { return 0; } else if (o1 == null) { // null is less return -1; } else if (o2 == null) { return 1; } int answer = compare(o1.getPublicID(), o2.getPublicID()); if (answer == 0) { answer = compare(o1.getSystemID(), o2.getSystemID()); if (answer == 0) { answer = compare(o1.getName(), o2.getName()); } } return answer; }
DocumentType doctype = (DocumentType) node; if ("publicId".equals(localName)) { result.add(new DefaultAttribute("publicId", doctype.getPublicID())); } else if ("systemId".equals(localName)) { result.add(new DefaultAttribute("systemId", doctype.getSystemID())); } else if ("elementName".equals(localName)) { result.add(new DefaultAttribute("elementName", doctype.getElementName()));
public void endDTD() throws SAXException { insideDTDSection = false; DocumentType docType = getDocument().getDocType(); if (docType != null) { if (internalDTDDeclarations != null) { docType.setInternalDeclarations(internalDTDDeclarations); } if (externalDTDDeclarations != null) { docType.setExternalDeclarations(externalDTDDeclarations); } } internalDTDDeclarations = null; externalDTDDeclarations = null; }
/** * Constructs a STAX {@link DTD}event from a DOM4J {@link DocumentType}. * * @param docType * The {@link DocumentType}from which to construct the event. * * @return The constructed {@link DTD}event. * * @throws RuntimeException * DOCUMENT ME! */ public DTD createDTD(DocumentType docType) { StringWriter decl = new StringWriter(); try { docType.write(decl); } catch (IOException e) { throw new RuntimeException("Error writing DTD", e); } return factory.createDTD(decl.toString()); }
protected void entityResolver(Document document) throws SAXException { if (entityResolver != null) { DocumentType docType = document.getDocType(); if (docType != null) { String publicID = docType.getPublicID(); String systemID = docType.getSystemID(); if ((publicID != null) || (systemID != null)) { try { entityResolver.resolveEntity(publicID, systemID); } catch (IOException e) { throw new SAXException("Could not resolve publicID: " + publicID + " systemID: " + systemID, e); } } } } }
public int compare(DocumentType o1, DocumentType o2) { if (o1 == o2) { return 0; } else if (o1 == null) { // null is less return -1; } else if (o2 == null) { return 1; } int answer = compare(o1.getPublicID(), o2.getPublicID()); if (answer == 0) { answer = compare(o1.getSystemID(), o2.getSystemID()); if (answer == 0) { answer = compare(o1.getName(), o2.getName()); } } return answer; }
DocumentType doctype = (DocumentType)node; if ("publicId".equals(localName)) { result.add(new DefaultAttribute("publicId", doctype.getPublicID())); result.add(new DefaultAttribute("systemId", doctype.getSystemID())); result.add(new DefaultAttribute("elementName", doctype.getElementName()));