Search in sources :

Example 1 with EmptyEntityResolver

use of com.helger.xml.sax.EmptyEntityResolver in project ph-commons by phax.

the class MicroReaderTest method testReadEntity.

@Test
public void testReadEntity() {
    // Read file with notation
    final IMicroDocument doc = MicroReader.readMicroXML(new ClassPathResource("xml/xml-entity-public.xml"), new SAXReaderSettings().setEntityResolver(new EmptyEntityResolver()));
    assertNotNull(doc);
    final MicroSAXHandler aHdl = new MicroSAXHandler(true, new EmptyEntityResolver(), true);
    final ISAXReaderSettings aSettings = new SAXReaderSettings().setEntityResolver(aHdl).setDTDHandler(aHdl).setContentHandler(aHdl).setErrorHandler(aHdl).setLexicalHandler(aHdl);
    assertTrue(SAXReader.readXMLSAX(InputSourceFactory.create(ClassPathResource.getInputStream("xml/xml-entity-public.xml")), aSettings).isSuccess());
    assertNotNull(aHdl.getDocument());
    // Write again
    assertNotNull(MicroWriter.getNodeAsString(doc));
}
Also used : ISAXReaderSettings(com.helger.xml.serialize.read.ISAXReaderSettings) ISAXReaderSettings(com.helger.xml.serialize.read.ISAXReaderSettings) SAXReaderSettings(com.helger.xml.serialize.read.SAXReaderSettings) IMicroDocument(com.helger.xml.microdom.IMicroDocument) EmptyEntityResolver(com.helger.xml.sax.EmptyEntityResolver) ClassPathResource(com.helger.commons.io.resource.ClassPathResource) Test(org.junit.Test)

Aggregations

ClassPathResource (com.helger.commons.io.resource.ClassPathResource)1 IMicroDocument (com.helger.xml.microdom.IMicroDocument)1 EmptyEntityResolver (com.helger.xml.sax.EmptyEntityResolver)1 ISAXReaderSettings (com.helger.xml.serialize.read.ISAXReaderSettings)1 SAXReaderSettings (com.helger.xml.serialize.read.SAXReaderSettings)1 Test (org.junit.Test)1