Search in sources :

Example 21 with OMFactory

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

the class TestGetAttributeTypeDefault method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMNamespace ns = factory.createOMNamespace("http://www.me.com", "axiom");
    OMAttribute at = factory.createOMAttribute("id", ns, "value");
    assertEquals("CDATA", at.getAttributeType());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMNamespace(org.apache.axiom.om.OMNamespace) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 22 with OMFactory

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

the class TestGetNamespaceURIWithoutNamespace method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMAttribute attr = factory.createOMAttribute("name", null, "value");
    assertNull(attr.getNamespaceURI());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMAttribute(org.apache.axiom.om.OMAttribute)

Example 23 with OMFactory

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

the class OMElementTest method testAddLLOMTextChildToDOOM.

public void testAddLLOMTextChildToDOOM() throws XMLStreamException {
    OMFactory doomFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
    OMFactory llomFactory = OMAbstractFactory.getOMFactory();
    String text = "This was a DOOM Text";
    OMElement doomRoot = doomFactory.createOMElement("root", null);
    OMText llomText = llomFactory.createOMText(text);
    OMComment comment = llomFactory.createOMComment(null, "comment");
    doomRoot.addChild(llomText);
    doomRoot.addChild(comment);
    OMElement newElement = (OMXMLBuilderFactory.createStAXOMBuilder(this.factory, doomRoot.getXMLStreamReader())).getDocumentElement();
    newElement.build();
    assertEquals(newElement.getText(), text);
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) OMComment(org.apache.axiom.om.OMComment) OMText(org.apache.axiom.om.OMText) OMElement(org.apache.axiom.om.OMElement)

Example 24 with OMFactory

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

the class RegisterCustomBuilderForPayloadJAXBTestCase method createTestDocument.

protected final OMElement createTestDocument(DataHandler dh) {
    OMFactory factory = metaFactory.getOMFactory();
    OMElement document = factory.createOMElement(new QName("urn:test", "document"));
    OMElement name = factory.createOMElement(new QName("name"));
    name.setText("some name");
    document.addChild(name);
    OMElement content = factory.createOMElement(new QName("content"));
    content.addChild(factory.createOMText(dh, true));
    document.addChild(content);
    return document;
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement)

Example 25 with OMFactory

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

the class TestGetOMDocumentElementWithParser method runTest.

@Override
protected void runTest() throws Throwable {
    OMFactory factory = metaFactory.getOMFactory();
    OMDocument document = OMXMLBuilderFactory.createOMBuilder(factory, new StringReader("<!-- comment --><root/><!-- comment -->")).getDocument();
    OMElement documentElement = document.getOMDocumentElement();
    assertNotNull(documentElement);
    assertEquals("root", documentElement.getLocalName());
}
Also used : OMFactory(org.apache.axiom.om.OMFactory) StringReader(java.io.StringReader) OMElement(org.apache.axiom.om.OMElement) OMDocument(org.apache.axiom.om.OMDocument)

Aggregations

OMFactory (org.apache.axiom.om.OMFactory)254 OMElement (org.apache.axiom.om.OMElement)189 OMNamespace (org.apache.axiom.om.OMNamespace)94 QName (javax.xml.namespace.QName)62 StringReader (java.io.StringReader)37 OMText (org.apache.axiom.om.OMText)35 OMSourcedElement (org.apache.axiom.om.OMSourcedElement)32 OMAttribute (org.apache.axiom.om.OMAttribute)31 PullOMDataSource (org.apache.axiom.ts.om.sourcedelement.util.PullOMDataSource)26 StringWriter (java.io.StringWriter)18 OMDocument (org.apache.axiom.om.OMDocument)18 XMLStreamReader (javax.xml.stream.XMLStreamReader)14 OMNode (org.apache.axiom.om.OMNode)14 DataHandler (javax.activation.DataHandler)12 OMException (org.apache.axiom.om.OMException)12 DataSource (javax.activation.DataSource)11 StringOMDataSource (org.apache.axiom.om.ds.StringOMDataSource)9 RandomDataSource (org.apache.axiom.testutils.activation.RandomDataSource)9 OMXMLParserWrapper (org.apache.axiom.om.OMXMLParserWrapper)8 Element (org.w3c.dom.Element)8