Java Code Examples for javax.xml.stream.events.DTD#getEntities()
The following examples show how to use
javax.xml.stream.events.DTD#getEntities() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SupportDTDTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
void DisplayEntities(DTD event) { List entities = event.getEntities(); if (entities == null) { _hasEntityDelaration = false; print("No entity found."); } else { _hasEntityDelaration = true; for (int i = 0; i < entities.size(); i++) { EntityDeclaration entity = (EntityDeclaration) entities.get(i); print(entity.getName()); } } }
Example 2
Source File: Issue41Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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()); } }
Example 3
Source File: Issue48Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * 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; List entities = dtd.getEntities(); if (entities == null) { Assert.fail("No entity found. Expected 3."); } else { Assert.assertEquals(entities.size(), 3); } // Let's also verify they are all of right type... testListElems(entities, EntityDeclaration.class); List notations = dtd.getNotations(); if (notations == null) { Assert.fail("No notation found. Expected 2."); } else { Assert.assertEquals(notations.size(), 2); } // Let's also verify they are all of right type... testListElems(notations, NotationDeclaration.class); } catch (Exception e) { Assert.fail(e.getMessage()); } }