Package javax.xml.transform.sax

Examples of javax.xml.transform.sax.SAXSource


  public URIResolver asURIResolver() {
    return new URIResolver() {
      public Source resolve(String href, String base) throws TransformerException {
        try {
          final InputSource src = SystemIdResolver.this.resolveEntity(null, null, base, href);
          return (src == null) ? null : new SAXSource(src);
        } catch (IOException ioe) {
          throw new TransformerException("Cannot resolve entity", ioe);
        }
      }
    };
View Full Code Here


            SAXParser parser = sfactory.newSAXParser();
            xmlReader = parser.getXMLReader();
        } catch (Exception ex) {
            LOG.warn("Cannot create the SAXParser XMLReader, due to {}", ex);
        }
        return new SAXSource(xmlReader, 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

    @Test
    public void testMarshalXMLSources() throws Exception {
        InputStream inStream = getClass().getResourceAsStream("testMessage1.xml");
        DOMSource inDOM = context.getTypeConverter().convertTo(DOMSource.class, inStream);
        inStream = getClass().getResourceAsStream("testMessage1.xml");
        SAXSource inSAX = context.getTypeConverter().convertTo(SAXSource.class, inStream);
        inStream = getClass().getResourceAsStream("testMessage1.xml");
        Document inDocument = context.getTypeConverter().convertTo(Document.class, inStream);

        // save the expected body of the message to set it later
        Object expectedBody = template.requestBody("direct:marshal", inDOM);
View Full Code Here

    try {
      is = stream.getStream();
      final String charset = ContentStreamBase.getCharsetFromContentType(stream.getContentType());
      final InputSource isrc = new InputSource(is);
      isrc.setEncoding(charset);
      final SAXSource source = new SAXSource(isrc);
      t.transform(source, result);
    } catch(TransformerException te) {
      throw new SolrException(SolrException.ErrorCode.BAD_REQUEST, te.getMessage(), te);
    } finally {
      IOUtils.closeQuietly(is);
View Full Code Here

            XMLReader xr = XMLReaderFactory.createXMLReader();
            xr.setEntityResolver(
                new ParseSupport.JstlEntityResolver(pageContext));
            InputSource s = new InputSource((Reader) o);
            s.setSystemId(wrapSystemId(systemId));
            Source result = new SAXSource(xr, s);
            result.setSystemId(wrapSystemId(systemId));
      return result;
        } else if (o instanceof Node) {
      return new DOMSource((Node) o);
        } else if (o instanceof List) {
      // support 1-item List because our XPath processor outputs them 
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

    public SAXSource toSAXSourceFromDOM(DOMSource source, Exchange exchange) throws TransformerException {
        if (DOM_TO_SAX_CLASS != null) {
            try {
                Constructor<?> cns = DOM_TO_SAX_CLASS.getConstructor(Node.class);
                XMLReader converter = (XMLReader) cns.newInstance(source.getNode());
                return new SAXSource(converter, new InputSource());
            } catch (Exception e) {
                throw new TransformerException(e);
            }
        } else {
            String str = toString(source, exchange);
            StringReader reader = new StringReader(str);
            return new SAXSource(new InputSource(reader));
        }
    }
View Full Code Here

                        in = blob.getStream();
                    } catch (RepositoryException e) {
                        throw new IOException(e.getMessage());
                    }
                    try {
                        SAXSource source =
                                new SAXSource(parser,
                                        new InputSource(in));
                        transformer.transform(source, result);

                        String text = parser.getContents();
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.