Search in sources :

Example 1 with DOMMetaFactory

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

the class EclipseTest method testDOOM.

@Test
public void testDOOM() throws Exception {
    DOMMetaFactory metaFactory = (DOMMetaFactory) OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
    Document document = metaFactory.newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    Element element = document.createElementNS("urn:test", "p:root");
    assertEquals(new QName("urn:test", "root"), ((OMElement) element).getQName());
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 2 with DOMMetaFactory

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

the class TestCreateDocumentFragmentInterfaces method runTest.

@Override
protected void runTest() throws Throwable {
    Document document = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    DocumentFragment fragment = document.createDocumentFragment();
    assertFalse(fragment instanceof OMInformationItem);
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) OMInformationItem(org.apache.axiom.om.OMInformationItem) Document(org.w3c.dom.Document) DocumentFragment(org.w3c.dom.DocumentFragment)

Example 3 with DOMMetaFactory

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

the class TestGetOMFactory1 method runTest.

@Override
protected void runTest() throws Throwable {
    Document document = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    assertSame(metaFactory.getOMFactory(), ((OMDocument) document).getOMFactory());
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) Document(org.w3c.dom.Document) OMDocument(org.apache.axiom.om.OMDocument)

Example 4 with DOMMetaFactory

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

the class TestSetValueOnNamespaceDeclaration method runTest.

@Override
protected void runTest() throws Throwable {
    Document doc = ((DOMMetaFactory) metaFactory).newDocumentBuilderFactory().newDocumentBuilder().newDocument();
    Element element = doc.createElementNS("", "test");
    Attr attr = doc.createAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:attr");
    element.setAttributeNodeNS(attr);
    attr.setValue("urn:test");
    Iterator<OMNamespace> it = ((OMElement) element).getAllDeclaredNamespaces();
    assertThat(it.hasNext()).isTrue();
    OMNamespace ns = it.next();
    assertThat(ns.getNamespaceURI()).isEqualTo("urn:test");
    assertThat(it.hasNext()).isFalse();
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMElement(org.apache.axiom.om.OMElement) Element(org.w3c.dom.Element) OMElement(org.apache.axiom.om.OMElement) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

Example 5 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();
    Attr attr = doc.createAttributeNS(null, "attr");
    assertNull(((OMAttribute) attr).getNamespace());
}
Also used : DOMMetaFactory(org.apache.axiom.om.dom.DOMMetaFactory) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr)

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