if (!setSupportExternalEntities(f, true)) {
reportNADueToExtEnt("testExternalEntityWithResolver");
return;
}
setResolver(f, new SimpleResolver(ENTITY_VALUE1));
// First, simple content without further expansion etc
XMLStreamReader sr = constructStreamReader(f, XML);
assertTokenType(DTD, sr.next());
assertTokenType(START_ELEMENT, sr.next());
assertTokenType(CHARACTERS, sr.next());
assertEquals(ACTUAL_VALUE1, getAndVerifyText(sr));
assertTokenType(END_ELEMENT, sr.next());
sr.close();
// Then bit more complicated one:
String ENTITY_VALUE2 = "external entity: <leaf /> this & that &intEnt;";
String ACTUAL_VALUE2a = "ent='external entity: ";
String ACTUAL_VALUE2b = " this & that & more!'";
String XML2 =
"<!DOCTYPE root [\n"
+"<!ENTITY extEnt SYSTEM 'myurl'>\n"
+"<!ENTITY intEnt '& more!'>\n"
+"]><root>ent='&extEnt;'</root>";
setResolver(f, new SimpleResolver(ENTITY_VALUE2));
sr = constructStreamReader(f, XML2);
assertTokenType(DTD, sr.next());
assertTokenType(START_ELEMENT, sr.next());
assertTokenType(CHARACTERS, sr.next());