/**
* DTDEvent instances constructed via event reader are missing the notation
* and entity declaration information
*/
@Test
public void testDTDEvent() {
String XML = "<?xml version='1.0' ?>" + "<!DOCTYPE root [\n" + "<!ENTITY intEnt 'internal'>\n" + "<!ENTITY extParsedEnt SYSTEM 'url:dummy'>\n"
+ "<!NOTATION notation PUBLIC 'notation-public-id'>\n" + "<!NOTATION notation2 SYSTEM 'url:dummy'>\n"
+ "<!ENTITY extUnparsedEnt SYSTEM 'url:dummy2' NDATA notation>\n" + "]>" + "<root />";
try {
XMLEventReader er = getReader(XML);
XMLEvent evt = er.nextEvent(); // StartDocument
evt = er.nextEvent(); // DTD
if (evt.getEventType() != XMLStreamConstants.DTD) {
Assert.fail("Expected DTD event");
}
DTD dtd = (DTD) evt;
writeAsEncodedUnicode(dtd);
List entities = dtd.getEntities();
if (entities == null) {
Assert.fail("No entity found. Expected 3.");
} else {
writeAsEncodedUnicode((XMLEvent) entities.get(0));
writeAsEncodedUnicode((XMLEvent) entities.get(1));
writeAsEncodedUnicode((XMLEvent) entities.get(2));
}
List notations = dtd.getNotations();
if (notations == null) {
Assert.fail("No notation found. Expected 2.");
} else {
writeAsEncodedUnicode((XMLEvent) notations.get(0));
writeAsEncodedUnicode((XMLEvent) notations.get(1));
}
} catch (Exception e) {
Assert.fail(e.getMessage());
}
}
Issue41Test.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录