Package javax.xml.transform.stax

Examples of javax.xml.transform.stax.StAXResult


  @Test
  public void marshalJaxp14StaxResultStreamWriter() throws Exception {
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    StringWriter writer = new StringWriter();
    XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(writer);
    StAXResult result = new StAXResult(streamWriter);
    marshaller.marshal(flights, result);
    assertXMLEqual("Marshaller writes invalid StreamResult", EXPECTED_STRING, writer.toString());
  }
View Full Code Here


  @Test
  public void marshalJaxp14StaxResultEventWriter() throws Exception {
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    StringWriter writer = new StringWriter();
    XMLEventWriter eventWriter = outputFactory.createXMLEventWriter(writer);
    StAXResult result = new StAXResult(eventWriter);
    marshaller.marshal(flights, result);
    assertXMLEqual("Marshaller writes invalid StreamResult", EXPECTED_STRING, writer.toString());
  }
View Full Code Here

  @Test
  public void isStaxResultJaxp14() throws Exception {
    XMLOutputFactory outputFactory = XMLOutputFactory.newInstance();
    XMLStreamWriter streamWriter = outputFactory.createXMLStreamWriter(new StringWriter());
    StAXResult result = new StAXResult(streamWriter);

    assertTrue("Not a StAX Result", StaxUtils.isStaxResult(result));
  }
View Full Code Here

    public void validate(Source source, Result result) throws SAXException,
            IOException {
        if (result instanceof StAXResult || result == null) {
            StAXSource staxSource = (StAXSource) source;
            StAXResult staxResult = (StAXResult) result;
            try {
                XMLStreamReader streamReader = staxSource.getXMLStreamReader();
                if (streamReader != null) {
                    // Hand off to XMLStreamReader helper.
                    if (fStreamHelper == null) {
View Full Code Here

            XMLOutputFactory outputFactory = new JsonXMLOutputFactory();
            outputFactory.setProperty(JsonXMLOutputFactory.PROP_AUTO_ARRAY, true);
            outputFactory.setProperty(JsonXMLOutputFactory.PROP_PRETTY_PRINT, true);
            StringWriter writer = new StringWriter();
            XMLStreamWriter output = outputFactory.createXMLStreamWriter(writer);
            Result result = new StAXResult(output);

            doTransform(message, enc, source, result);
            return writer.toString();
        }
        catch (Exception ex)
View Full Code Here

     */
    protected String convert(Source source, XMLOutputFactory factory) throws XMLStreamException, TransformerException
    {
        StringWriter writer = new StringWriter();
        XMLStreamWriter output = factory.createXMLStreamWriter(writer);
        Result result = new StAXResult(output);
        Transformer transformer = transformerFactory.newTransformer();
        transformer.transform(source, result);
        return writer.toString();
    }
View Full Code Here

            }
            Source source = new StAXSource(reader);

            XMLStreamWriter writer = new JsonXMLOutputFactory(config, new JacksonStreamFactory())
                    .createXMLStreamWriter(outputStream, charSetEncoding);
            Result result = new StAXResult(writer);
            String backupProp = System.getProperty("javax.xml.transform.TransformerFactory");
            System.setProperty("javax.xml.transform.TransformerFactory",
                    "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
            TransformerFactory.newInstance().newTransformer().transform(source, result);
            System.setProperty("javax.xml.transform.TransformerFactory", backupProp);
View Full Code Here

     * @param  out Where to write to.
     * @return The writer.
     * @throws XMLStreamException If the writer can not be created.
     */
    public static XMLStreamWriter createXMLStreamWriter(final XMLEventWriter out) throws XMLStreamException {
        return FACTORY.createXMLStreamWriter(new StAXResult(out));
    }
View Full Code Here

            throw Exceptions.resultInstantiation(ex);
        } catch (ClassCastException ex) {
            throw Exceptions.resultInstantiation(ex);
        }

        StAXResult          staxResult = createStAXResult(null);
        XMLStreamWriter     xmlWriter  = staxResult.getXMLStreamWriter();
        SAX2XMLStreamWriter handler    = new SAX2XMLStreamWriter(xmlWriter);

        result.setHandler(handler);

        return (T) result;
View Full Code Here

     */
    @SuppressWarnings("unchecked")
    protected <T extends Result>T createStAXResult(
            Class<T> resultClass) throws SQLException {

        StAXResult       result       = null;
        OutputStream     outputStream = this.setBinaryStreamImpl();
        Constructor      ctor;
        XMLOutputFactory factory;
        XMLStreamWriter  xmlStreamWriter;

        try {
            factory         = XMLOutputFactory.newInstance();
            xmlStreamWriter = factory.createXMLStreamWriter(outputStream);

            if (resultClass == null) {
                result = new StAXResult(xmlStreamWriter);
            } else {
                ctor   = resultClass.getConstructor(XMLStreamWriter.class);
                result = (StAXResult) ctor.newInstance(xmlStreamWriter);
            }
        } catch (SecurityException ex) {
View Full Code Here

TOP

Related Classes of javax.xml.transform.stax.StAXResult

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.