Package javax.xml.stream

Examples of javax.xml.stream.XMLStreamWriter


        ByteArrayOutputStream out = new ByteArrayOutputStream();

        OutMessage message = new OutMessage("urn:bleh");
        message.setBody(fault);
        XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, "UTF-8",null);
        writer.writeStartDocument();
        writer.writeStartElement("soap", "Body", Soap12.getInstance().getNamespace());
        writer.setPrefix("soap", Soap12.getInstance().getNamespace());
        writer.writeNamespace("soap", Soap12.getInstance().getNamespace());
        soap12.writeMessage(message, writer, new MessageContext());
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.close();
       
        Document doc = readDocument(out.toString());
        //printNode(doc);
        addNamespace("s", Soap12.getInstance().getNamespace());
        assertValid("//s:SubCode/s:Value[text()='m:NotAvailable']", doc);
View Full Code Here


        ByteArrayOutputStream out = new ByteArrayOutputStream();
       
        OutMessage message = new OutMessage("urn:bleh");
        message.setBody(fault);
       
        XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, "UTF-8",null);
        writer.writeStartDocument();
        writer.writeStartElement("soap", "Body", Soap11.getInstance().getNamespace());
        writer.writeNamespace("soap", Soap11.getInstance().getNamespace());
        soap11.writeMessage(message, writer, new MessageContext());
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.close();

        Document doc = readDocument(out.toString());

        addNamespace("s", Soap12.getInstance().getNamespace());
        addNamespace("t", "urn:test2");
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
       
        OutMessage message = new OutMessage("urn:bleh");
        message.setBody(fault);
       
        XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, "UTF-8",null);
        writer.writeStartDocument();
        writer.writeStartElement("soap", "Body", Soap11.getInstance().getNamespace());
        writer.writeNamespace("soap", Soap11.getInstance().getNamespace());
        soap11.writeMessage(message, writer, new MessageContext());
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.close();

        Document doc = readDocument(out.toString());

        addNamespace("s", Soap12.getInstance().getNamespace());
        addNamespace("t", "urn:test2");
View Full Code Here

        ByteArrayOutputStream out = new ByteArrayOutputStream();
       
        OutMessage message = new OutMessage("urn:bleh");
        message.setBody(fault);
       
        XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(out, "UTF-8",null);
        writer.writeStartDocument();
        writer.writeStartElement("soap", "Body", Soap12.getInstance().getNamespace());
        writer.writeNamespace("soap", Soap12.getInstance().getNamespace());
        soap11.writeMessage(message, writer, new MessageContext());
        writer.writeEndElement();
        writer.writeEndDocument();
        writer.close();

        Document doc = readDocument(out.toString());

        addNamespace("s", Soap12.getInstance().getNamespace());
        addNamespace("t", "urn:test2");
View Full Code Here

        ctx.setProperty(XFire.STAX_INPUT_FACTORY, MyInputFactory.class.getName());
        ctx.setProperty(XMLInputFactory.IS_COALESCING, "false");
        XMLStreamReader xmlReader = STAXUtils.createXMLStreamReader(new StringReader(xml), ctx);

        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLStreamWriter xmlWriter = STAXUtils.createXMLStreamWriter(outStream, null, null);
        STAXUtils.copy(xmlReader, xmlWriter);
        xmlWriter.close();
        xmlReader.close();
        outStream.close();
        System.out.println(outStream.toString());
        String result = outStream.toString();
        assertTrue(result.indexOf("CDATA") > 0);
View Full Code Here

    {
        try
        {
            IMarshallingContext mctx = bfact.createMarshallingContext();

            XMLStreamWriter noCloseWriter = new NoCloseXMLStreamWriter(((ElementWriter) writer)
                    .getXMLStreamWriter());
            mctx.setXmlWriter(new StAXWriter(bfact.getNamespaces(), noCloseWriter));

            mctx.marshalDocument(object);
        }
View Full Code Here

       
        XMLStreamReader reader = STAXUtils.createXMLStreamReader(getResourceAsStream("amazon.xml"), null, ctx);
       
        ctx.setProperty(XFire.STAX_OUTPUT_FACTORY, WstxOutputFactory.class.getName());
       
        XMLStreamWriter writer = STAXUtils.createXMLStreamWriter(new ByteArrayOutputStream(), null, ctx);
    }
View Full Code Here

    {
        String in = new String("<hello xmlns=\"\">world</hello>");
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        XMLStreamReader reader = ifactory.createXMLStreamReader(new StringReader(in));
        XMLStreamWriter writer = ofactory.createXMLStreamWriter(out);
        STAXUtils.copy(reader, writer);
        writer.close();
        out.close();
        System.out.println(out.toString());
        assertEquals(in, out.toString());
    }
View Full Code Here

    private String doCopy(String resource) throws FactoryConfigurationError, XMLStreamException
    {
        XMLStreamReader reader = ifactory.createXMLStreamReader(getClass().getResourceAsStream(resource));
       
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        XMLStreamWriter writer = ofactory.createXMLStreamWriter(out);
       
        writer.writeStartDocument();
        STAXUtils.copy(reader, writer);
        writer.writeEndDocument();
       
        writer.close();
        String outS = out.toString();
       
        return outS;
    }
View Full Code Here

    public void doDOMWrite() throws Exception
    {
        org.w3c.dom.Document doc = DOMUtils.readXml(getResourceAsStream("amazon.xml"));

        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLStreamWriter writer = ofactory.createXMLStreamWriter(bos);
       
        STAXUtils.writeElement(doc.getDocumentElement(), writer, false);
       
        writer.close();
       
        Document testDoc = readDocument(bos.toString(), ifactory);
        addNamespace("a", "http://xml.amazon.com/AWSECommerceService/2004-08-01");
        assertValid("//a:ItemLookup", testDoc);
        assertValid("//a:ItemLookup/a:Request", testDoc);
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLStreamWriter

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.