Package org.apache.axiom.om

Examples of org.apache.axiom.om.OMDocument


                                     XMLStreamWriter writer)
    throws XMLStreamException {
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        builder.releaseParserOnClose(true);
        try {
            OMDocument omDocument = builder.getDocument();
            Iterator it = omDocument.getChildren();
            while (it.hasNext()) {
                OMNode omNode = (OMNode) it.next();
                omNode.serializeAndConsume(writer);
            }
        } finally {
View Full Code Here


    public void testSerializeToXMLWriterFromReader() throws Exception {
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);

        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(element.getXMLStreamReader());
        OMDocument omDocument = builder.getDocument();
        Iterator it = omDocument.getChildren();
        while (it.hasNext()) {
            OMNode omNode = (OMNode) it.next();
            // TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
            omNode.getNextOMSibling();
            omNode.serializeAndConsume(xmlwriter);
View Full Code Here

    public void testSerializeToXMLWriterFromReaderEmbedded() throws Exception {
        StringWriter writer = new StringWriter();
        XMLStreamWriter xmlwriter = StAXUtils.createXMLStreamWriter(writer);

        OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(root.getXMLStreamReader());
        OMDocument omDocument = builder.getDocument();
        Iterator it = omDocument.getChildren();
        while (it.hasNext()) {
            OMNode omNode = (OMNode) it.next();
            // TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
            omNode.getNextOMSibling();
            omNode.serializeAndConsume(xmlwriter);
View Full Code Here

     * @throws Exception
     */
    public void testDeferredLoadingOfAttachments() throws Exception {
        MTOMStAXSOAPModelBuilder builder = createBuilderForTestMTOMMessage();
        Attachments attachments = builder.getAttachments();
        OMDocument doc = builder.getDocument();
        // Find all the binary nodes
        List/*<OMText>*/ binaryNodes = new ArrayList();
        for (Iterator it = new OMDescendantsIterator(doc.getFirstOMChild()); it.hasNext(); ) {
            OMNode node = (OMNode)it.next();
            if (node instanceof OMText) {
                OMText text = (OMText)node;
                if (text.isBinary()) {
                    binaryNodes.add(text);
View Full Code Here

                                     XMLStreamWriter writer)
    throws XMLStreamException {
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        builder.releaseParserOnClose(true);
        try {
            OMDocument omDocument = builder.getDocument();
            Iterator it = omDocument.getChildren();
            while (it.hasNext()) {
                OMNode omNode = (OMNode) it.next();
                omNode.serializeAndConsume(writer);
            }
        } finally {
View Full Code Here

                                     XMLStreamWriter writer)
    throws XMLStreamException {
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        builder.releaseParserOnClose(true);
        try {
            OMDocument omDocument = builder.getDocument();
            Iterator it = omDocument.getChildren();
            while (it.hasNext()) {
                OMNode omNode = (OMNode) it.next();
                omNode.serializeAndConsume(writer);
            }
        } finally {
View Full Code Here

public class TransformTest extends TestCase {
   
    public void testTransform() throws Exception {
        OMFactory fac = new OMDOMFactory();
        OMDocument doc = fac.createOMDocument();
        OMElement element = fac.createOMElement(new QName("http://foo", "bar"));
        OMText text = fac.createOMText("test");
        element.addChild(text);
        doc.addChild(element);

        Document domDoc1 = ((ElementImpl)element).getOwnerDocument();
        assertNotNull(domDoc1);
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here

            // create a SOAPMessage to hold the SOAP envelope and assign the SOAP envelope in that.
            soapMessage = soapFactory.createSOAPMessage(this);
            // TODO: this needs to be reviewed; why do we create an OMDocument in StAXOMBuilder and
            //       then replace it here
            OMDocument orgDocument = this.document;
            soapMessage.setXMLEncoding(orgDocument.getXMLEncoding());
            this.document = soapMessage;
            if (charEncoding != null) {
                document.setCharsetEncoding(charEncoding);
            }
View Full Code Here

    private static void reader2writer(XMLStreamReader reader,
                                     XMLStreamWriter writer) throws XMLStreamException {
        StAXOMBuilder builder = new StAXOMBuilder(reader);
        builder.releaseParserOnClose(true);
        try {
            OMDocument omDocument = builder.getDocument();
            Iterator it = omDocument.getChildren();
            while (it.hasNext()) {
                // TODO: this is extremely inefficient since next() will actually build the node!
                OMNode omNode = (OMNode) it.next();
                // TODO: quick fix required because OMChildrenIterator#next() no longer builds the node
                omNode.getNextOMSibling();
View Full Code Here

        namespaceURIInterning = false;
        lookAheadToken = -1;
    }

    private OMDocument createDocument() {
        OMDocument document = omfactory.createOMDocument(this);
        if (charEncoding != null) {
            document.setCharsetEncoding(charEncoding);
        }
        if (parser.getEventType() == XMLStreamConstants.START_DOCUMENT) {
            document.setXMLVersion(parser.getVersion());
            document.setXMLEncoding(parser.getCharacterEncodingScheme());
            document.setStandalone(parser.isStandalone() ? "yes" : "no");
        } else {
            // We allow creating a StAXOMWrapper from a parser in state START_ELEMENT. In that
            // case, we must not call getVersion or isStandalone since this is forbidden by the
            // StAX specs. Set some reasonable defaults.
            document.setXMLVersion("1.0");
            document.setStandalone("yes");
        }
        return document;
    }
View Full Code Here

TOP

Related Classes of org.apache.axiom.om.OMDocument

Copyright © 2018 www.massapicom. 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.