Search in sources :

Example 6 with DOMMetaFactory

use of org.apache.axiom.om.dom.DOMMetaFactory in project webservices-axiom by apache.

the class TestImportNode method runTest.

@Override
protected void runTest() throws Throwable {
    Document doc = DOMImplementation.XERCES.parse(new InputSource(file.getUrl().toString()));
    Document doc2 = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    Node n = doc2.importNode(doc.getDocumentElement(), true);
    assertAbout(xml()).that(xml(OMElement.class, (OMElement) n)).treatingElementContentWhitespaceAsText().hasSameContentAs(xml(Element.class, doc.getDocumentElement()));
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) InputSource(org.xml.sax.InputSource) Node(org.w3c.dom.Node) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) Document(org.w3c.dom.Document)

Example 7 with DOMMetaFactory

use of org.apache.axiom.om.dom.DOMMetaFactory in project webservices-axiom by apache.

the class TestDetach method runTest.

@Override
protected void runTest() throws Throwable {
    Document document = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    Element parent = document.createElementNS(null, "parent");
    Element child = document.createElementNS(null, "child");
    parent.appendChild(child);
    ((OMElement) child).detach();
    assertNotSame(document, child.getOwnerDocument());
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) Document(org.w3c.dom.Document)

Example 8 with DOMMetaFactory

use of org.apache.axiom.om.dom.DOMMetaFactory in project webservices-axiom by apache.

the class TestGetNamespaceNormalized method runTest.

@Override
protected void runTest() throws Throwable {
    Document doc = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    Element element = doc.createElementNS(null, "test");
    assertNull(((OMElement) element).getNamespace());
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document)

Aggregations

DOMMetaFactory (org.apache.axiom.om.dom.DOMMetaFactory)8 Document (org.w3c.dom.Document)8 OMElement (org.apache.axiom.om.OMElement)5 Element (org.w3c.dom.Element)5 Attr (org.w3c.dom.Attr)2 QName (javax.xml.namespace.QName)1 OMDocument (org.apache.axiom.om.OMDocument)1 OMInformationItem (org.apache.axiom.om.OMInformationItem)1 OMNamespace (org.apache.axiom.om.OMNamespace)1 Test (org.junit.Test)1 DocumentFragment (org.w3c.dom.DocumentFragment)1 Node (org.w3c.dom.Node)1 InputSource (org.xml.sax.InputSource)1