Package org.apache.cxf.aegis.xml.stax

Examples of org.apache.cxf.aegis.xml.stax.ElementWriter


        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();

        Document doc = StaxUtils.read(new ByteArrayInputStream(bos.toByteArray()));
        Element element = doc.getDocumentElement();
View Full Code Here


        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();
       
        Document doc = DOMUtils.readXml(new ByteArrayInputStream(bos.toByteArray()));
        Element element = doc.getDocumentElement();
View Full Code Here

                if (part.getXmlSchema() instanceof XmlSchemaElement
                    && ((XmlSchemaElement)part.getXmlSchema()).getMinOccurs() == 0) {
                    //skip writing minOccurs=0 stuff if obj is null
                    return;
                } else if (type.isNillable() && type.isWriteOuter()) {
                    ElementWriter writer = new ElementWriter(output);
                    MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
                    w2.writeXsiNil();
                    w2.close();
                    return;
                }
            }
            ElementWriter writer = new ElementWriter(output);
            MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
            type.writeObject(obj, w2, context);
            w2.close();
        } catch (DatabindingException e) {
            throw new RuntimeException(e);
        }
View Full Code Here

        try {
            writer.setNamespaceContext(namespaceContext);
        } catch (XMLStreamException e) {
            throw new RuntimeException(e);
        }
        return new ElementWriter(writer);
    }
View Full Code Here

        return writeObjectToElement(type, bean, getContext());
    }

    protected Element writeObjectToElement(Type type, Object bean, Context context) {
        Element element = createElement("urn:Bean", "root", "b");
        ElementWriter writer = getElementWriter(element, new MapNamespaceContext());
        type.writeObject(bean, writer, getContext());
        writer.close();
        return element;
    }
View Full Code Here

                if (part.getXmlSchema() instanceof XmlSchemaElement
                    && ((XmlSchemaElement)part.getXmlSchema()).getMinOccurs() == 0) {
                    //skip writing minOccurs=0 stuff if obj is null
                    return;
                } else if (type.isNillable() && type.isWriteOuter()) {
                    ElementWriter writer = new ElementWriter(output);
                    MessageWriter w2 = writer.getElementWriter(part.getConcreteName());
                    w2.writeXsiNil();
                    w2.close();
                    return;
                }
            }
            ElementWriter writer = new ElementWriter(output);
            MessageWriter w2 = writer.getElementWriter(part != null ? part.getConcreteName()
                : type.getSchemaType());
            type.writeObject(obj, w2, context);
            w2.close();
        } catch (DatabindingException e) {
            throw new RuntimeException(e);
View Full Code Here

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();
       
        Document doc = DOMUtils.readXml(new ByteArrayInputStream(bos.toByteArray()));
        Element element = doc.getDocumentElement();
View Full Code Here

        if (obj == null) {
            if (optional) { // minOccurs = 0
                return;
            }
            if (aegisType.isNillable() && aegisType.isWriteOuter()) {
                ElementWriter writer = new ElementWriter(output);
                MessageWriter w2 = writer.getElementWriter(elementName);
                w2.writeXsiNil();
                w2.close();
                return;
            }
        }
       
        ElementWriter writer = new ElementWriter(output);
        MessageWriter w2 = writer.getElementWriter(elementName);
        if (getContext().isWriteXsiTypes()
            && aegisType != null
            && aegisType.getSchemaType() != null) {
            // if we know the type, write it. We are standalone, and the reader needs it.
            w2.writeXsiType(aegisType.getSchemaType());
View Full Code Here

        if (obj == null) {
            if (optional) { // minOccurs = 0
                return;
            }
            if (aegisType.isNillable() && aegisType.isWriteOuter()) {
                ElementWriter writer = new ElementWriter(output);
                MessageWriter w2 = writer.getElementWriter(elementName);
                w2.writeXsiNil();
                w2.close();
                return;
            }
        }
       
        ElementWriter writer = new ElementWriter(output);
        MessageWriter w2 = writer.getElementWriter(elementName);
        if (getContext().isWriteXsiTypes()
            && aegisType != null
            && aegisType.getSchemaType() != null) {
            // if we know the type, write it. We are standalone, and the reader needs it.
            w2.writeXsiType(aegisType.getSchemaType());
View Full Code Here

        reader.getXMLStreamReader().close();

        // Test writing

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ElementWriter writer = new ElementWriter(bos, "root", "urn:Bean");
        type.writeObject(bean, writer, getContext());
        writer.close();
        writer.flush();

        bos.close();
       
        Document doc = DOMUtils.readXml(new ByteArrayInputStream(bos.toByteArray()));
        Element element = doc.getDocumentElement();
View Full Code Here

TOP

Related Classes of org.apache.cxf.aegis.xml.stax.ElementWriter

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.