Package javax.xml.stream

Examples of javax.xml.stream.XMLOutputFactory.createXMLEventWriter()


        part.setElementQName(elName);
       
        StringWriter stringWriter = new StringWriter();
        XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
        opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
        XMLEventWriter writer = opFactory.createXMLEventWriter(stringWriter);
        JAXBEncoderDecoder.marshall(context.createMarshaller(), testObject, part, writer);
        writer.flush();
        writer.close();
        String xmlResult = stringWriter.toString();
        // the following is a bit of a crock, but, to tell the truth, this test case most exists
View Full Code Here


        part.setElementQName(elName);
       
        StringWriter stringWriter = new StringWriter();
        XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
        opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
        XMLEventWriter writer = opFactory.createXMLEventWriter(stringWriter);
        Marshaller m = context.createMarshaller();
        JAXBUtils.setNamespaceWrapper(mapper, m);
        JAXBEncoderDecoder.marshall(m, testObject, part, writer);
        writer.flush();
        writer.close();
View Full Code Here

        part.setElementQName(elName);
               
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
        opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
        XMLEventWriter writer = opFactory.createXMLEventWriter(baos);

        //STARTDOCUMENT/ENDDOCUMENT is not required
        //writer.add(eFactory.createStartDocument("utf-8", "1.0"));       
        JAXBEncoderDecoder.marshall(context.createMarshaller(), obj, part, writer);
        //writer.add(eFactory.createEndDocument());
View Full Code Here

        obj.setRequestType("Hello");
       
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        XMLOutputFactory opFactory = XMLOutputFactory.newInstance();
        opFactory.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, Boolean.TRUE);
        XMLEventWriter writer = opFactory.createXMLEventWriter(baos);

        //STARTDOCUMENT/ENDDOCUMENT is not required
        //writer.add(eFactory.createStartDocument("utf-8", "1.0"));       
        JAXBEncoderDecoder.marshall(context.createMarshaller(), obj, null, writer);
        //writer.add(eFactory.createEndDocument());
View Full Code Here

        XMLEventReader eventReader = inputFactory.createXMLEventReader(payload.getInputStream());
        Source staxSource = StaxUtils.createCustomStaxSource(eventReader);
        transformer.transform(staxSource, webServiceMessage.getPayloadResult());
        StringWriter stringWriter = new StringWriter();
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(stringWriter);
        Result staxResult = StaxUtils.createCustomStaxResult(eventWriter);
        transformer.transform(webServiceMessage.getPayloadSource(), staxResult);
        eventWriter.flush();
        assertXMLEqual(getExpectedString(), stringWriter.toString());
        validateMessage();
View Full Code Here

    }

    @Test
    public void testDoWithStaxResultEventWriter() throws Exception {
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(new StringWriter());

        TraxUtils.ResultCallback mock = createMock(TraxUtils.ResultCallback.class);
        mock.staxResult(eventWriter);

        replay(mock);
View Full Code Here

  public void translate(InputStream in, OutputStream out) throws XMLStreamException {
    final XMLInputFactory inFactory = XMLInputFactory.newInstance();
    final XMLOutputFactory outFactory = XMLOutputFactory.newInstance();

    final XMLEventReader reader = inFactory.createXMLEventReader(in);
    final XMLEventWriter writer = outFactory.createXMLEventWriter(out);

    try {
      EventLoop: while (reader.hasNext()) {
        XMLEvent event = reader.nextEvent();
View Full Code Here

    private XMLEventWriter writer;
    private XMLEventFactory factory;

    public FeatureMetaDataExporter(OutputStream out) throws XMLStreamException {
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        writer = outputFactory.createXMLEventWriter(out);
        factory = XMLEventFactory.newInstance();
        StartDocument startDocument = factory.createStartDocument();
        writer.add(startDocument);
        newLine();
        writer.add(factory.createStartElement("", "", "features"));
View Full Code Here

        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:
View Full Code Here

    private XMLEventWriter writer;
    private XMLEventFactory factory;

    public FeatureMetaDataExporter(OutputStream out) throws XMLStreamException {
        XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
        writer = outputFactory.createXMLEventWriter(out);
        factory = XMLEventFactory.newInstance();
        StartDocument startDocument = factory.createStartDocument();
        writer.add(startDocument);
        newLine();
        writer.add(factory.createStartElement("", "", "features"));
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.