XercesSax implements ContentHandler { public String getElementContent(String tagName) { int startIndex = this.result.indexOf(tagName); String content = ""; if (startIndex > -1) { for (int i = startIndex+1; i < this.result.size(); i++) { if (this.result.get(i) != tagName) { content += this.result.get(i); } else { break; } } content = content.replaceAll("\\n",""); } return content; } XercesSax(); void startElement(String namespace, String localName, 
          String qualifiedName, Attributes attribs); void characters(char[] ch, int start, int length); void endElement(String namespaceURI, String localName,
                          String qualifiedName); void endPrefixMapping(String prefix); void ignorableWhitespace(char[] ch, int start, 
                                   int length); void processingInstruction(String target, String data); void setDocumentLocator(Locator l); void skippedEntity(String name); void startDocument(); void endDocument(); void startPrefixMapping(String prefix, String uri); List<String> getResult(); List<String> getResultAttributes(); String getElementContent(String tagName); String getAttributeValue(String attributeName); static void main(String[] args);  }
@Test public void testInternalSubset_PEReferenceIn_ExternalSubsetInternalGeneralEntity() throws IOException, SAXException { parser.setProperty("http: parser.parse("../../xml_files/dtd/internalSubset_PEReferenceIn_ExternalSubsetInternalGeneralEntity.xml"); assertEquals("file: myDeclHandler.getEntityValue("%goodies")); assertEquals("file: myDeclHandler.getEntityValue("%dtd")); assertEquals("<![CDATA[secret]]>", myDeclHandler.getEntityValue("all")); assertEquals("secret", myContentHandler.getElementContent("data")); }
@Test public void testExternalSubset_ExternalPEReferenceIn_ExternalSubset_InternalGeneralEntity() throws IOException, SAXException { parser.setProperty("http: parser.parse("../../xml_files/dtd/externalSubset_ExternalPEReferenceIn_ExternalSubset_InternalGeneralEntity.xml"); assertEquals("file: +"externalSubset_ExternalPEReferenceIn_ExternalSubset_InternalGeneralEntity_source.txt", myDeclHandler.getEntityValue("%goodies")); assertEquals("<!ENTITY all '<![CDATA[hier sind die goodies]]>'>", myDeclHandler.getEntityValue("%dtd")); assertEquals("<![CDATA[hier sind die goodies]]>", myDeclHandler.getEntityValue("all")); assertEquals("hier sind die goodies", myContentHandler.getElementContent("data")); }