Package javax.xml.transform.stax

Examples of javax.xml.transform.stax.StAXSource


    if (sourceClass == null || sourceClass == StreamSource.class) {
      return (T)new StreamSource(getBinaryStream(), this.getStreamFactory().getSystemId());
    } else if (sourceClass == StAXSource.class) {
      XMLInputFactory factory = XMLInputFactory.newInstance();
      try {
        return (T) new StAXSource(factory.createXMLStreamReader(getBinaryStream()));
      } catch (XMLStreamException e) {
        throw new SQLException(e);
      }
    } else if (sourceClass == SAXSource.class) {
      return (T) new SAXSource(new InputSource(getBinaryStream()));
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    protected <T extends Source>T createStAXSource(
            Class<T> sourceClass) throws SQLException {

        StAXSource      source      = null;
        Constructor     sourceCtor  = null;
        Reader          reader      = null;
        XMLInputFactory factory     = null;
        XMLEventReader  eventReader = null;

View Full Code Here

        XMLSecurityStreamReader xmlSecurityStreamReader = new XMLSecurityStreamReader(inputProcessorChain, securityProperties);
        //use the sun internal TransformerFactory since the current xalan version don't know how to handle StaxSources:
        TransformerFactory transformerFactory = TransformerFactory.newInstance("com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl", this.getClass().getClassLoader());
        javax.xml.transform.Transformer transformer = transformerFactory.newTransformer();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        transformer.transform(new StAXSource(xmlSecurityStreamReader), new StreamResult(baos));
        XMLAssert.assertXMLEqual(readTestFile(), baos.toString("UTF-8"));
    }
View Full Code Here

        QName opQName = new QName("http://apache.org/hello_world_soap_http", "greetMe");
        disp.getRequestContext().put(MessageContext.WSDL_OPERATION, opQName);
       
        // Test request-response
        InputStream is = getClass().getResourceAsStream("resources/GreetMeDocLiteralSOAPBodyReq.xml");
        StAXSource staxSourceReq = new StAXSource(StaxUtils.createXMLStreamReader(is));
        assertNotNull(staxSourceReq);
        Source resp = disp.invoke(staxSourceReq);
        assertNotNull(resp);
        assertTrue(resp instanceof StAXSource);
        String expected = "Hello TestSOAPInputMessage";
View Full Code Here

            StaxSource ss = (StaxSource)source;
            if (ss.getXMLStreamReader() == null) {
                return;
            }
        } else if (source instanceof StAXSource) {
            StAXSource ss = (StAXSource)source;
            if (ss.getXMLStreamReader() == null) {
                return;
            }
        } else if (source instanceof SAXSource) {
            SAXSource ss = (SAXSource)source;
            InputSource src = ss.getInputSource();
            if (src == null || (src.getSystemId() == null && src.getPublicId() == null)) {
                if (ss.getXMLReader() != null) {
                    //OK - reader is OK.  We'll use that out
                    StreamWriterContentHandler ch = new StreamWriterContentHandler(writer);
                    XMLReader reader = ((SAXSource)source).getXMLReader();
                    reader.setContentHandler(ch);
                    try {
                        try {
                            reader.setFeature("http://xml.org/sax/features/namespaces", true);
                        } catch (Throwable t) {
                            //ignore
                        }
                        try {
                            reader.setProperty("http://xml.org/sax/properties/lexical-handler", ch);
                        } catch (Throwable t) {
                            //ignore
                        }
                        reader.parse(((SAXSource)source).getInputSource());
                        return;
                    } catch (Exception e) {
                        throw new XMLStreamException(e.getMessage(), e);
                    }
                } else if (ss.getInputSource() == null) {
                    //nothing to copy, just return
                    return;
                }
            }
      
        } else if (source instanceof StreamSource) {
            StreamSource ss = (StreamSource)source;
            if (ss.getInputStream() == null
                && ss.getReader() == null
                && ss.getSystemId() == null) {
                //nothing to copy, just return
                return;
            }
        }
        XMLStreamReader reader = createXMLStreamReader(source);
View Full Code Here

        private static boolean isStaxSource(Class<?> clazz) {
            return StAXSource.class.isAssignableFrom(clazz);
        }

        private static Source createStaxSource(XMLStreamReader streamReader, String systemId) {
            return new StAXSource(new SystemIdStreamReaderDelegate(streamReader, systemId));
        }
View Full Code Here

     * @throws XMLStreamException
     */
    @Converter
    public StAXSource toStAXSource(String source, Exchange exchange) throws XMLStreamException {
        XMLStreamReader r = new StaxConverter().createXMLStreamReader(new StringReader(source));
        return new StAXSource(r);
    }
View Full Code Here

     * @throws XMLStreamException
     */
    @Converter
    public StAXSource toStAXSource(byte[] in, Exchange exchange) throws XMLStreamException {
        XMLStreamReader r = new StaxConverter().createXMLStreamReader(new ByteArrayInputStream(in), exchange);
        return new StAXSource(r);
    }
View Full Code Here

     * @throws XMLStreamException
     */
    @Converter
    public StAXSource toStAXSource(InputStream source, Exchange exchange) throws XMLStreamException {
        XMLStreamReader r = new StaxConverter().createXMLStreamReader(source, exchange);
        return new StAXSource(r);
    }
View Full Code Here

     */
    @Converter
    public StAXSource toStAXSource(File file, Exchange exchange) throws FileNotFoundException, XMLStreamException {
        InputStream is = IOHelper.buffered(new FileInputStream(file));
        XMLStreamReader r = new StaxConverter().createXMLStreamReader(is, exchange);
        return new StAXSource(r);
    }
View Full Code Here

TOP

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

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.