Search in sources :

Example 1 with XmlReader

use of org.apache.axiom.core.stream.XmlReader in project webservices-axiom by apache.

the class SerializerConformanceTest method runTest.

@Override
protected void runTest() throws Throwable {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setExpandEntityReferences(false);
    Document document = factory.newDocumentBuilder().parse(sample.getUrl().toString());
    StringWriter sw = new StringWriter();
    XmlReader reader = new DOMInput(document, false).createReader(new Serializer(sw));
    while (!reader.proceed()) {
    // Just loop
    }
    InputSource is = new InputSource(new StringReader(sw.toString()));
    is.setSystemId(sample.getUrl().toString());
    assertAbout(xml()).that(is).ignoringWhitespaceInPrologAndEpilog().treatingElementContentWhitespaceAsText().hasSameContentAs(document);
}
Also used : DOMInput(org.apache.axiom.core.stream.dom.DOMInput) InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) StringWriter(java.io.StringWriter) StringReader(java.io.StringReader) XmlReader(org.apache.axiom.core.stream.XmlReader) Document(org.w3c.dom.Document)

Aggregations

StringReader (java.io.StringReader)1 StringWriter (java.io.StringWriter)1 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)1 XmlReader (org.apache.axiom.core.stream.XmlReader)1 DOMInput (org.apache.axiom.core.stream.dom.DOMInput)1 Document (org.w3c.dom.Document)1 InputSource (org.xml.sax.InputSource)1