Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMElement.addChild()


   
    public void testCDATAEvent_FromElement() throws Exception {
        OMFactory omfactory = omMetaFactory.getOMFactory();
        OMElement element = omfactory.createOMElement("test", null);
        OMText cdata = omfactory.createOMText("hello world", OMNode.CDATA_SECTION_NODE);
        element.addChild(cdata);
       
        // Get the XMLStreamReader for the element. This will return an OMStAXWrapper.
        XMLStreamReader reader2 = element.getXMLStreamReader();
        // Check the sequence of events
        int event = reader2.next();
View Full Code Here


    }
   
      DataHandler dataHandler = new DataHandler(dataSource);

      OMText textData = fac.createOMText(dataHandler, true);
      attachmentElem.addChild(textData);
   
    pingElem.addChild(attachmentElem);

    return pingElem;
  }
View Full Code Here

        OMElement image    = factory.createOMElement("image", ns);

        FileDataSource fileDataSource = new FileDataSource(tempFile);
        dataHandler = new DataHandler(fileDataSource);
        OMText textData = factory.createOMText(dataHandler, true);
        image.addChild(textData);
        response.addChild(image);
        payload.addChild(response);

        MessageContext outMsgCtx = MessageContext.getCurrentMessageContext()
            .getOperationContext().getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE);
View Full Code Here

    protected void runTest() throws Throwable {
        OMFactory omFactory = metaFactory.getOMFactory();
        OMDataSource ds = new CharArrayDataSource("<a>test</a>".toCharArray());
        OMElement root = omFactory.createOMElement(new QName("root"));
        OMSourcedElement child = omFactory.createOMElement(ds, "a", null);
        root.addChild(child);
        assertFalse(child.isExpanded());
        XMLStreamReader stream = root.getXMLStreamReader();
        assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
        assertEquals("root", stream.getLocalName());
        assertEquals(XMLStreamReader.START_ELEMENT, stream.next());
View Full Code Here

        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;
    }
   
    private void test(DataHandler dh, StAXOMBuilder builder, boolean same, boolean usesAttachments, boolean expectBareReader) throws IOException {
View Full Code Here

public class XOPRoundtripTest extends TestCase {
    public void test() {
        OMFactory factory = OMAbstractFactory.getOMFactory();
        DataHandler dh = new DataHandler(new TestDataSource('x', Runtime.getRuntime().maxMemory()));
        OMElement element1 = factory.createOMElement(new QName("test"));
        element1.addChild(factory.createOMText(dh, true));
        XMLStreamReader originalReader = element1.getXMLStreamReader();
        XOPEncodingStreamReader encodedReader = new XOPEncodingStreamReader(originalReader,
                ContentIDGenerator.DEFAULT, OptimizationPolicy.DEFAULT);
        XMLStreamReader decodedReader = new XOPDecodingStreamReader(encodedReader, encodedReader);
        OMElement element2 = OMXMLBuilderFactory.createStAXOMBuilder(decodedReader).getDocumentElement();
View Full Code Here

        expectedDH = new DataHandler(dataSource);
        OMText binaryNode = fac.createOMText(expectedDH, true);

        envelope.addChild(body);
        body.addChild(data);
        data.addChild(binaryNode);

        envelope.serializeAndConsume(new FileOutputStream(outBase64File), baseOutputFormat);
        envelope.serializeAndConsume(new FileOutputStream(outMTOMFile), mtomOutputFormat);
    }
View Full Code Here

   
    public void test() throws XMLStreamException {
        SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
        SOAPEnvelope env = factory.getDefaultEnvelope();
        OMElement element = factory.createOMElement(new QName("urn:testService", "invokeMtom", "ns"), env.getBody());
        element.addChild(factory.createOMText(new DataHandler("test", "text/xml"), true));
        logMessage1(env);
        logMessage2(env);
    }
}
View Full Code Here

        OMNamespace rootNS = f.createOMNamespace("http://sampleroot", "rootPrefix");
        OMNamespace ns = f.createOMNamespace("", "");
        OMElement element =
                f.createOMElement(new TestDataSource(testDocument3), "library", ns);
        OMElement root = f.createOMElement("root", rootNS);
        root.addChild(element);

        // Test getting the namespace, localpart and prefix.  This should used not result in expansion
        assertTrue(element.getLocalName().equals("library"));
        assertNull(element.getNamespace());
View Full Code Here

        OMNamespace ns = factory.createOMNamespace("urn://test", "tns");
        ByteArrayDataSource bads1 = new ByteArrayDataSource(payload1.getBytes(encoding), encoding);

        OMElement parent = factory.createOMElement("root", null);
        OMSourcedElement omse = factory.createOMElement(bads1, localName, ns);
        parent.addChild(omse);
        OMNode firstChild = parent.getFirstOMChild();
        assertTrue("Expected OMSourcedElement child", firstChild instanceof OMSourcedElement);
        OMSourcedElement child = (OMSourcedElement) firstChild;
        assertTrue("OMSourcedElement is expanded.  This is unexpected", !child.isExpanded());
        assertTrue("OMSourcedElement should be backed by a ByteArrayDataSource",
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.