@Test
public void testReplacing() throws Exception {
XMLInputFactory factory = XMLInputFactory.newInstance();
factory.setProperty("javax.xml.stream.isReplacingEntityReferences", true);
StringReader sr = new StringReader(XML);
XMLEventReader reader = factory.createXMLEventReader(sr);
boolean sawUndef = false;
boolean sawDef = false;
while (reader.hasNext()) {
XMLEvent event = reader.nextEvent();
// System.out.println("Event: " + event);
if (event.isEntityReference()) {
EntityReference ref = (EntityReference) event;
if ("def".equals(ref.getName())) {
sawDef = true;
} else if ("undef".equals(ref.getName())) {
sawUndef = true;
} else {
throw new IllegalArgumentException("Unexpected entity name");
}
}
}
Assert.assertEquals(false, sawDef);
Assert.assertEquals(true, sawUndef);
reader.close();
}
Bug6555001.java 文件源码
java
阅读 20
收藏 0
点赞 0
评论 0
项目:openjdk9
作者:
评论列表
文章目录