Search in sources :

Example 1 with DOMInput

use of org.apache.axiom.core.stream.dom.DOMInput 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)

Example 2 with DOMInput

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

the class StAXPivotTransformerTest method runTest.

@Override
protected void runTest() throws Throwable {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setExpandEntityReferences(false);
    factory.setCoalescing(true);
    factory.setIgnoringComments(true);
    Document document = factory.newDocumentBuilder().parse(sample.getUrl().toString());
    StAXPivot pivot = new StAXPivot(null);
    pivot.setReader(new DOMInput(document, false).createReader(pivot));
    StringWriter sw = new StringWriter();
    xsltImplementation.newTransformerFactory().newTransformer().transform(new StAXSource(pivot), new StreamResult(sw));
    assertAbout(xml()).that(sw.toString()).hasSameContentAs(document);
}
Also used : DOMInput(org.apache.axiom.core.stream.dom.DOMInput) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) StringWriter(java.io.StringWriter) StreamResult(javax.xml.transform.stream.StreamResult) StAXSource(javax.xml.transform.stax.StAXSource) Document(org.w3c.dom.Document)

Example 3 with DOMInput

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

the class StAXPivotTest method setUp.

@Before
public void setUp() throws Exception {
    Document document = DOMImplementation.XERCES.newDocument();
    Element element = document.createElementNS("urn:test", "p:test");
    document.appendChild(element);
    element.appendChild(document.createEntityReference("ent"));
    pivot = new StAXPivot(null);
    pivot.setReader(new DOMInput(document, false).createReader(pivot));
}
Also used : DOMInput(org.apache.axiom.core.stream.dom.DOMInput) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Before(org.junit.Before)

Aggregations

DOMInput (org.apache.axiom.core.stream.dom.DOMInput)3 Document (org.w3c.dom.Document)3 StringWriter (java.io.StringWriter)2 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)2 StringReader (java.io.StringReader)1 StAXSource (javax.xml.transform.stax.StAXSource)1 StreamResult (javax.xml.transform.stream.StreamResult)1 XmlReader (org.apache.axiom.core.stream.XmlReader)1 Before (org.junit.Before)1 Element (org.w3c.dom.Element)1 InputSource (org.xml.sax.InputSource)1