Package javax.xml.stream

Examples of javax.xml.stream.XMLEventWriter


        if (soap == null || !soap.startsWith("<"))
            return null;
       
        final XMLEventReader xmlReader = XML_INPUT_FACTORY.createXMLEventReader(new StringReader(soap));
        final StringWriter stringWriter = new StringWriter();
        final XMLEventWriter xmlWriter = XML_OUTPUT_FACTORY.createXMLEventWriter(stringWriter);
       
        while(xmlReader.hasNext())
        {
            XMLEvent event = xmlReader.nextEvent();
            if (isStartOfHeader(event))
            {
                while (xmlReader.hasNext())
                {
                  event = xmlReader.nextEvent();
                if (isStartOfAssertion(event))
                {
                    xmlWriter.add(event);
                    while (xmlReader.hasNext())
                    {
                        XMLEvent nextEvent = xmlReader.nextEvent();
                        xmlWriter.add(nextEvent);
                        if (isEndOfAssertion(nextEvent))
                        {
                      xmlWriter.flush();
                      return stringWriter.toString();
                        }
                    }
                }
               
View Full Code Here


                    if (found)
                    {
                        throw new SOAPException("Found multiple SOAPElements in SOAPBody") ;
                    }
                    final StringWriter sw = new StringWriter() ;
                    final XMLEventWriter writer = XMLHelper.getXMLEventWriter(new StreamResult(sw)) ;
                    XMLHelper.readDomNode(node, writer, true) ;
                    requestProxy.setPayload(esbReq, sw.toString()) ;
                    found = true ;
                }
            }
View Full Code Here

     */
    public static Document createDocument(XMLEventReader reader)
        throws ParserConfigurationException, XMLStreamException
    {
        final Document doc = getNewDocument() ;
        final XMLEventWriter writer = EVENT_WRITER_CREATOR.createXMLEventWriter(doc);
        XMLHelper.copyXMLEventStream(reader, writer) ;
        return doc;
    }
View Full Code Here

     * @return
     * @throws Exception
     */
    private File removeDoctype(File fileToProcess) throws Exception {
        XMLEventReader eventReader = null;
        XMLEventWriter eventWriter = null;

        XMLInputFactory inputFactory = XMLInputFactory.newFactory();
        XMLOutputFactory outputFactory = XMLOutputFactory.newFactory();

        FileInputStream fis = new FileInputStream(fileToProcess);
        File output = File.createTempFile("config-test-nodoctype", ".xml", new File("target/"));
        output.deleteOnExit();
        FileOutputStream fos = new FileOutputStream(output);

        eventReader = inputFactory.createXMLEventReader(fis);
        eventWriter = outputFactory.createXMLEventWriter(fos);

        while(eventReader.hasNext()) {
            XMLEvent xmlEvent = eventReader.nextEvent();
            switch(xmlEvent.getEventType()) {
                case XMLEvent.DTD:
                    // We have DTD declaration, remove it by skipping it
                    break;
                default:
                    eventWriter.add(xmlEvent);
                    break;
            }
        }
        eventReader.close();
        eventWriter.close();

        return output;
    }
View Full Code Here

        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
            assertTrue(false);
        }
        assertNotNull(evtWriter);
       
        XMLEventFactory factory = XMLEventFactory.newInstance();
        try {
            bindingImpl.writeObjectToStax(obj, evtWriter, factory, false);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
            assertTrue(false);
        }
       
        byte[] b = outStream.toByteArray();
View Full Code Here

        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
        }
        assertNotNull(evtWriter);
       
        try {
            XMLEventFactory factory = XMLEventFactory.newInstance();
            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
            evtWriter.add(startEl);
            simpleBindingImpl.writePrimitiveToStax(obj, evtWriter, factory);
            EndElement endEl = factory.createEndElement(obj.getName(), null);
            evtWriter.add(endEl);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
           
        }

        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());       
View Full Code Here

        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
        }
        assertNotNull(evtWriter);
       
        try {
            XMLEventFactory factory = XMLEventFactory.newInstance();
            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
            evtWriter.add(startEl);
            staxBindingImpl.writeArrayToStax(obj, evtWriter, factory);
            EndElement endEl = factory.createEndElement(obj.getName(), null);
            evtWriter.add(endEl);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
           
        }

        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());       
View Full Code Here

        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
        }
        assertNotNull(evtWriter);
       
        try {
            XMLEventFactory factory = XMLEventFactory.newInstance();
            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
            evtWriter.add(startEl);
            staxBindingImpl.writeEnumToStax(obj, evtWriter, factory);
            EndElement endEl = factory.createEndElement(obj.getName(), null);
            evtWriter.add(endEl);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
           
        }

        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());       
View Full Code Here

        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
        }
        assertNotNull(evtWriter);
       
        try {
            XMLEventFactory factory = XMLEventFactory.newInstance();
            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
            evtWriter.add(startEl);
            staxBindingImpl.writeFixedToStax(obj, evtWriter, factory);
            EndElement endEl = factory.createEndElement(obj.getName(), null);
            evtWriter.add(endEl);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
           
        }

        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());       
View Full Code Here

        XMLInputFactory inputFactory = XMLInputFactory.newInstance();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        outputFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
     
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        XMLEventWriter evtWriter = null;
        try {
            evtWriter = outputFactory.createXMLEventWriter(outStream);
        } catch (XMLStreamException ex) {
        }
        assertNotNull(evtWriter);
       
        try {
            XMLEventFactory factory = XMLEventFactory.newInstance();
            StartElement startEl = factory.createStartElement(obj.getName(), null, null);
            evtWriter.add(startEl);
            staxBindingImpl.writeSequenceToStax(obj, evtWriter, factory);
            EndElement endEl = factory.createEndElement(obj.getName(), null);
            evtWriter.add(endEl);
            evtWriter.flush();
        } catch (XMLStreamException ex) {
           
        }

        ByteArrayInputStream inStream = new ByteArrayInputStream(outStream.toByteArray());       
View Full Code Here

TOP

Related Classes of javax.xml.stream.XMLEventWriter

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.