Package javax.xml.transform

Examples of javax.xml.transform.Source


        document.setXmlStandalone(true);
        return document;
    }

    private void transform(Document document) throws TransformerConfigurationException, TransformerException {
        Source source = new DOMSource(document);
        Result result = new StreamResult(writer);
        Transformer transformer = TransformerFactory.newInstance().newTransformer();
        transformer.setOutputProperty(OutputKeys.INDENT, "yes");
        transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
        transformer.transform(source, result);
View Full Code Here


            //Write doc
            preset.writeXML(document);

            //Write XML file
            Source source = new DOMSource(document);
            Result result = new StreamResult(FileUtil.toFile(presetFile));
            Transformer transformer = TransformerFactory.newInstance().newTransformer();
            transformer.setOutputProperty(OutputKeys.INDENT, "yes");
            transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
            transformer.transform(source, result);
View Full Code Here

      TransformerFactory factory = TransformerFactory.newInstance();

      String xsltSystemId = getCanonicalURL(pageContext, _xsltSystemId);
     
      Source source = getSource(_xslt, xsltSystemId);

      Transformer transformer = factory.newTransformer(source);
      // transformer.setOutputProperty("omit-xml-declaration", "yes");

      for (int i = 0; i < _paramNames.size(); i++) {
        String name = _paramNames.get(i);
        String value = _paramValues.get(i);

        transformer.setParameter(name, value);
      }

      if (_xml != null)
        source = getSource(_xml, getCanonicalURL(pageContext, _xmlSystemId));
      else {
        BodyContent body = getBodyContent();
       
        TempCharReader tempReader = (TempCharReader) body.getReader();
        int ch;

        while (Character.isWhitespace((ch = tempReader.read()))) {
        }

        if (ch >= 0)
          tempReader.unread();
       
        source = new StreamSource(tempReader);

        if (_xmlSystemId != null)
          source.setSystemId(getCanonicalURL(pageContext, _xmlSystemId));
        else
          source.setSystemId(((HttpServletRequest) pageContext.getRequest()).getRequestURI());
      }

      Result result;
      Node top = null;
View Full Code Here

    throws JspException
  {
    PageContextImpl pageContext = (PageContextImpl) this.pageContext;
     
    Object xmlObj = xml;
    Source source = null;

    if (xmlObj instanceof String) {
      ReadStream is = Vfs.openString((String) xmlObj);

      source = new StreamSource(is, systemId);
View Full Code Here

              if (newPath.canRead())
                path = newPath;
            }
          }

          Source source;
          if (path.canRead())
            source = new StreamSource(path.getURL());
          else
            source = new StreamSource(href);

          if (log.isLoggable(Level.FINE))
            log.fine(L.l("'{0}' XSLT filter using stylesheet {1}",
                         req.getRequestURI(), source.getSystemId()));

          stylesheet = factory.newTemplates(source);
        } finally {
          // is.close();
        }
View Full Code Here

     
      JspWriter out = pageContext.getOut();

      TransformerFactory factory = TransformerFactory.newInstance();

      Source source = getSource(_xslt, _xsltSystemId);

      Transformer transformer = factory.newTransformer(source);

      for (int i = 0; i < _paramNames.size(); i++) {
        String name = _paramNames.get(i);
        String value = _paramValues.get(i);

        transformer.setParameter(name, value);
      }

      if (_xml != null)
        source = getSource(_xml, _xmlSystemId);
      else {
        BodyContent bodyContent = getBodyContent();

        source = new StreamSource(bodyContent.getReader());
        source.setSystemId(((HttpServletRequest) pageContext.getRequest()).getRequestURI());
      }

      Result result;
      Node top = null;
View Full Code Here

    try {
      PageContextImpl pageContext = (PageContextImpl) this.pageContext;
     
      Object xmlObj = xmlExpr.evalObject(pageContext.getELContext());
      String systemId = null;
      Source source = null;

      if (systemIdExpr != null)
        systemId = systemIdExpr.evalString(pageContext.getELContext());
     
      source = convertToSource(xmlObj, systemId);
View Full Code Here

      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      JAXWSUtil.extractSOAPBody(is, baos);
      ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());

      // invoke the provider
      Source ret = (Source) _provider.invoke(new StreamSource(bais));

      // Wrap and send the response
      OutputStreamWriter writer = new OutputStreamWriter(os);
      JAXWSUtil.writeStartSOAPEnvelope(writer, _soapNamespace);

      _transformer.transform(ret, new StreamResult(os));
      os.flush();

      JAXWSUtil.writeEndSOAPEnvelope(writer);
    }
    else {
      Source ret = (Source) _provider.invoke(new StreamSource(is));

      _transformer.transform(ret, new StreamResult(os));

      os.flush();
    }
View Full Code Here

    invoke(in, out);

    if (_handlerChain != null) {
      byte[] output = ((ByteArrayOutputStream) out).toByteArray();
      Source source = new StreamSource(new ByteArrayInputStream(output));
      DOMResult result = new DOMResult();

      _transformer.transform(source, result);

      out = response.getOutputStream();
View Full Code Here

     * configured or because {@link ResourceMap#resolve(SynapseConfiguration, String)}
     * returns null, it will resolve the location using
     * {@link SynapseConfigUtils#resolveRelativeURI(String, String)}.
     */
    public Source resolve(String href, String base) throws TransformerException {
        Source result = null;
        if (resourceMap != null) {
            InputSource is = resourceMap.resolve(synCfg, href);
            if (is != null) {
                result = new StreamSource(is.getByteStream());
            }
View Full Code Here

TOP

Related Classes of javax.xml.transform.Source

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.