Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.SAXSource


        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());
        HandlerChainsStringQNameAdapter adapter = new HandlerChainsStringQNameAdapter();
        adapter.setHandlerChainsNamespaceFilter(xmlFilter);
        unmarshaller.setAdapter(HandlerChainsStringQNameAdapter.class, adapter);

        SAXSource source = new SAXSource(xmlFilter, inputSource);

        currentPublicId.set(new TreeSet<String>());
        try {
            return unmarshaller.unmarshal(source);
        } finally {
View Full Code Here


       
        // get the xml filter
        Javaee6SchemaFilter xmlFilter = new Javaee6SchemaFilter(parser.getXMLReader());
       
        // get the source
        SAXSource sourceForValidate = new SAXSource(xmlFilter, new InputSource(in));
       
        // get the schema
        SchemaFactory schemaFactory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
       
        JaxbJavaeeSchemaResourceResolver resourceResolver = new JaxbJavaeeSchemaResourceResolver()
View Full Code Here

        } else {
            inputSource = new InputSource(source.getInputStream());
        }
        inputSource.setSystemId(source.getSystemId());
        inputSource.setPublicId(source.getPublicId());
        return new SAXSource(inputSource);
    }
View Full Code Here

   
    @Converter
    public SAXSource toSAXSourceFromDOM(DOMSource source, Exchange exchange) throws TransformerException {
        String str = toString(source, exchange);
        StringReader reader = new StringReader(str);
        return new SAXSource(new InputSource(reader));
    }
View Full Code Here

    @Converter
    public SAXSource toSAXSourceFromStAX(StAXSource source, Exchange exchange) throws TransformerException {
        String str = toString(source, exchange);
        StringReader reader = new StringReader(str);
        return new SAXSource(new InputSource(reader));
    }
View Full Code Here

        Source ret = null;
        if(src instanceof DOMSource) {
            DOMSource dsrc = (DOMSource)src;
            ret = new DOMSource(dsrc.getNode() != null ? dsrc.getNode().cloneNode(true) : null);
        } else if(src instanceof SAXSource) {
            SAXSource ssrc = (SAXSource)src;
            if(ssrc.getInputSource().getByteStream() != null) {
                InputStream inp = ssrc.getInputSource().getByteStream();
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                int b;
                try {
                    while((b = inp.read()) != -1) {
                        bout.write(b);
                    }
                } catch (IOException ignored) {
                }
                try { bout.close();} catch (IOException ignored) {}
                try { inp.reset();} catch (IOException ignored) {}
                ret = new SAXSource(new InputSource(new ByteArrayInputStream(bout.toByteArray())));
            } else if(ssrc.getInputSource().getCharacterStream() != null) {
                Reader rdr = ssrc.getInputSource().getCharacterStream();
                CharArrayWriter caw = new CharArrayWriter();
                try {
                    int c;
                    while((c = rdr.read()) != -1) {
                        caw.append((char)c);
                    }
                } catch (IOException ignored) {
                }
                caw.close();
                try{ rdr.reset();} catch(IOException ignored) {}
                ret = new SAXSource(new InputSource(new CharArrayReader(caw.toCharArray())));
            } else {
                ret = new SAXSource();
            }
        } else if(src instanceof StreamSource) {
            StreamSource ssrc = (StreamSource)src;
            if(ssrc.getInputStream() != null) {
                InputStream inp = ssrc.getInputStream();
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                int b;
                try {
                    while((b = inp.read()) != -1) {
                        bout.write(b);
                    }
                } catch (IOException ignored) {
                }
                try { bout.close();} catch (IOException ignored) {}
                try { inp.reset();} catch (IOException ignored) {}
                ret = new StreamSource(new ByteArrayInputStream(bout.toByteArray()));
            } else if(ssrc.getReader() != null) {
                Reader rdr = ssrc.getReader();
                CharArrayWriter caw = new CharArrayWriter();
                try {
                    int c;
                    while((c = rdr.read()) != -1) {
                        caw.append((char)c);
View Full Code Here


        NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());

        SAXSource source = new SAXSource(xmlFilter, inputSource);

        Object o = unmarshaller.unmarshal(source);
        if (o instanceof JAXBElement) {
            JAXBElement element = (JAXBElement) o;
            return (T) element.getValue();
View Full Code Here

        Source ret = null;
        if(src instanceof DOMSource) {
            DOMSource dsrc = (DOMSource)src;
            ret = new DOMSource(dsrc.getNode() != null ? dsrc.getNode().cloneNode(true) : null);
        } else if(src instanceof SAXSource) {
            SAXSource ssrc = (SAXSource)src;
            if(ssrc.getInputSource().getByteStream() != null) {
                InputStream inp = ssrc.getInputSource().getByteStream();
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                int b;
                try {
                    while((b = inp.read()) != -1) {
                        bout.write(b);
                    }
                } catch (IOException ignored) {
                }
                try { bout.close();} catch (IOException ignored) {}
                try { inp.reset();} catch (IOException ignored) {}
                ret = new SAXSource(new InputSource(new ByteArrayInputStream(bout.toByteArray())));
            } else if(ssrc.getInputSource().getCharacterStream() != null) {
                Reader rdr = ssrc.getInputSource().getCharacterStream();
                CharArrayWriter caw = new CharArrayWriter();
                try {
                    int c;
                    while((c = rdr.read()) != -1) {
                        caw.append((char)c);
                    }
                } catch (IOException ignored) {
                }
                caw.close();
                try{ rdr.reset();} catch(IOException ignored) {}
                ret = new SAXSource(new InputSource(new CharArrayReader(caw.toCharArray())));
            } else {
                ret = new SAXSource();
            }
        } else if(src instanceof StreamSource) {
            StreamSource ssrc = (StreamSource)src;
            if(ssrc.getInputStream() != null) {
                InputStream inp = ssrc.getInputStream();
                ByteArrayOutputStream bout = new ByteArrayOutputStream();
                int b;
                try {
                    while((b = inp.read()) != -1) {
                        bout.write(b);
                    }
                } catch (IOException ignored) {
                }
                try { bout.close();} catch (IOException ignored) {}
                try { inp.reset();} catch (IOException ignored) {}
                ret = new StreamSource(new ByteArrayInputStream(bout.toByteArray()));
            } else if(ssrc.getReader() != null) {
                Reader rdr = ssrc.getReader();
                CharArrayWriter caw = new CharArrayWriter();
                try {
                    int c;
                    while((c = rdr.read()) != -1) {
                        caw.append((char)c);
View Full Code Here

            PersistenceFilter xmlFilter = new PersistenceFilter(xmlReader);

            // Be sure the filter has the JAXB content handler set (or it wont
            // work)
            xmlFilter.setContentHandler(uh);
            SAXSource source = new SAXSource(xmlFilter, new InputSource(persistenceDescriptor));

            return (Persistence) u.unmarshal(source);

        } finally {
            if (persistenceDescriptor != null) persistenceDescriptor.close();
View Full Code Here


        NamespaceFilter xmlFilter = new NamespaceFilter(parser.getXMLReader());
        xmlFilter.setContentHandler(unmarshaller.getUnmarshallerHandler());

        SAXSource source = new SAXSource(xmlFilter, inputSource);

        return unmarshaller.unmarshal(source, type);
    }
View Full Code Here

TOP

Related Classes of javax.xml.transform.sax.SAXSource

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.