Package javax.xml.stream

Examples of javax.xml.stream.XMLEventWriter


        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();
        String xmlResult = stringWriter.toString();
        // the following is a bit of a crock, but, to tell the truth, this test case most exists
        // so that it could be examined inside the debugger to see how JAXB works.
        assertTrue(xmlResult.contains("Gallia:string2"));
    }
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());
        writer.flush();
        writer.close();
       
        //System.out.println(baos.toString());
       
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        XMLInputFactory ipFactory = XMLInputFactory.newInstance();
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());
        writer.flush();
        writer.close();
       
        //System.out.println(baos.toString());
       
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        XMLInputFactory ipFactory = XMLInputFactory.newInstance();
View Full Code Here

 
  @Override
  public  void saveRemoteReasonerConfiguration(File file){
   
    XMLOutputFactory factory = XMLOutputFactory.newInstance();
    XMLEventWriter writer = null;
    try {
      writer = factory.createXMLEventWriter(new FileOutputStream(file));
      saveRemoteReasonerConfiguration(writer);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
View Full Code Here

     */
    public static final void copy(XMLStreamReader reader, XMLStreamWriter writer)
            throws XMLStreamException {

        XMLEventReader r = inputFactory.createXMLEventReader(reader);
        XMLEventWriter w = new XMLStreamEventWriter(writer);

        try {

            w.add(r);

        } finally {

            // force any cached events to the underlying writer
            w.flush();

        }

    }
View Full Code Here

            factory = inputFactory;

        }

        XMLEventReader r = factory.createXMLEventReader(reader);
        XMLEventWriter w = new XMLStreamEventWriter(writer);

        try {

            w.add(r);

        } finally {

            // force any cached events to the underlying writer
            w.flush();

        }

    }
View Full Code Here

     *     result.
     */
    public static final void copy(XMLEventReader reader, Result result)
            throws XMLStreamException {

        XMLEventWriter writer = outputFactory.createXMLEventWriter(result);

        copy(reader, writer);

        // force any cached events to the result
        writer.flush();

    }
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);
        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
        // so that it could be examined inside the debugger to see how JAXB works.
        assertTrue(xmlResult.contains(":string2>cord</ns"));
    }
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.setNamespaceMapper(mapper, m);
        JAXBEncoderDecoder.marshall(m, 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
        // so that it could be examined inside the debugger to see how JAXB works.
        assertTrue(xmlResult.contains("Gallia:string2"));
    }
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());
        writer.flush();
        writer.close();
       
        //System.out.println(baos.toString());
       
        ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
        XMLInputFactory ipFactory = XMLInputFactory.newInstance();
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.