Package org.apache.xalan.xslt

Examples of org.apache.xalan.xslt.XSLTProcessor


    // perform Transformation
    if ((xmlSource != null) && (xslSource != null))
    {
    try
    { // new try ... catch around ctor Update -sc
        XSLTProcessor xslprocessor = org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
        {
          try
          {
            String contentType = null;
            if ((contentType = getContentType(xslprocessor.processStylesheet(xslSource))) != null)
              response.setContentType(contentType);
            xslprocessor.setQuietConflictWarnings(ourDefaultParameters.isNoCW(request));
            xslprocessor.setProblemListener(listener);
            if (debug)
            {
              ByteArrayOutputStream baos = new ByteArrayOutputStream();
              XSLTResultTarget outBuffer = new XSLTResultTarget(baos);
              setStylesheetParams(xslprocessor, request);
              xslprocessor.process(xmlSource, xslSource, outBuffer);
              baos.writeTo(response.getOutputStream());
              writeLog(listener.getMessage(), response.SC_OK);
            }
            else
            {
              setStylesheetParams(xslprocessor, request);
              xslprocessor.process(xmlSource, xslSource,
                                   new XSLTResultTarget(response.getWriter()));
            }
          }
          catch (Exception exc)
          {
            ApplyXSLException axe = new ApplyXSLException("Exception occurred during Transformation:"
                                                          + EOL + listener.getMessage() + EOL
                                                          + exc.getMessage(), exc,
                                                                              response.SC_INTERNAL_SERVER_ERROR);
            if (debug) writeLog(axe);
            displayException(response, axe, debug);
          }
          finally
          {
            xslprocessor.reset();
          } // end of try ... catch ... finally
        } // end of blank block
    }
      catch (org.xml.sax.SAXException saxExc)
      {
View Full Code Here


           java.net.MalformedURLException,
           org.xml.sax.SAXException
  {
    // Have the XSLTProcessorFactory obtain a interface to a
    // new XSLTProcessor object.
    XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

    // Have the XSLTProcessor processor object transform "foo.xml" to
    // System.out, using the XSLT instructions found in "foo.xsl".
    processor.process(new XSLTInputSource("foo.xml"),
                      new XSLTInputSource("foo.xsl"),
                      new XSLTResultTarget(System.out));
  }
View Full Code Here

  // Prepare an output source for the results
  XSLTResultTarget result =
      new XSLTResultTarget(pageContext.getOut());

  // Create an XSLT processor and use it to perform the transformation
  XSLTProcessor processor = null;
  try {
      processor = XSLTProcessorFactory.getProcessor();
      processor.process(data, style, result);
  } catch (SAXException e) {
      throw new JspException(e.toString());
  }
  return (EVAL_PAGE);
View Full Code Here

    throws JspException {

  try {
      // Have the XSLTProcessorFactory obtain a interface to a
      // new XSLTProcessor object.
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
     
      // Have the XSLTProcessor processor object transform "foo.xml" to
      // System.out, using the XSLT instructions found in "foo.xsl".
      processor.process(new XSLTInputSource(url),
            new XSLTInputSource(xsl),
            new XSLTResultTarget(out));
  } catch(SAXException sexp) {
      throw new JspException("SAXParser Exception: " + sexp.getMessage());     
  }
View Full Code Here

    throws JspException {

  try {
      // Have the XSLTProcessorFactory obtain a interface to a
      // new XSLTProcessor object.
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
     
      // Have the XSLTProcessor processor object transform "foo.xml" to
      // System.out, using the XSLT instructions found in "foo.xsl".
      processor.process(new XSLTInputSource(url),
            new XSLTInputSource(xsl),
            new XSLTResultTarget(out));
  } catch(SAXException sexp) {
      throw new JspException("SAXParser Exception: " + sexp.getMessage());     
  }
View Full Code Here

      } else {
        writer = new StringWriter();
      }

      // Use XSLTProcessorFactory to instantiate an XSLTProcessor.
      XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

      // Create the 3 objects the XSLTProcessor needs to perform the transformation.
      XSLTInputSource xmlSource  = new XSLTInputSource (args[0]);
      XSLTInputSource xslSheet   = new XSLTInputSource (args[1]);
      XSLTResultTarget xmlResult = new XSLTResultTarget (writer);

      // Perform the transformation.
      processor.process(xmlSource, xslSheet, xmlResult);
     
      if (usefile) {
        reader = new FileReader(args[2]+".tmp");
      } else {
        // create a input source containing the xsl:fo file which can be fed to Fop 
View Full Code Here

            } else {
                writer = new StringWriter();
            }

            // Use XSLTProcessorFactory to instantiate an XSLTProcessor.
            XSLTProcessor processor = XSLTProcessorFactory.getProcessor();

            // Create the 3 objects the XSLTProcessor needs to perform the transformation.
            // Fix up the args...
            XMLParserLiaison xmlPL = processor.getXMLProcessorLiaison();
            URL urlTmp = xmlPL.getURLFromString(args[0], null);
            System.err.println("XML File: " + args[0]);
            System.err.println("URL: " + urlTmp);
            XSLTInputSource xmlSource =
              new XSLTInputSource (urlTmp.toString());
            urlTmp = xmlPL.getURLFromString(args[1], null);
            System.err.println("XSL File: " + args[1]);
            System.err.println("URL: " + urlTmp);
            XSLTInputSource xslSheet =
              new XSLTInputSource (urlTmp.toString());

            XSLTResultTarget xmlResult = new XSLTResultTarget (writer);

            // Perform the transformation.
            processor.process(xmlSource, xslSheet, xmlResult);

            if (usefile) {
                reader = new FileReader(args[2] + ".tmp");
            } else {
                // create a input source containing the xsl:fo file which can be fed to Fop
View Full Code Here

        }


        Document doc = new DocumentImpl();
        try {
            XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
            XSLTInputSource  xml  = new XSLTInputSource(argv[0]);
            XSLTInputSource  xslt = new XSLTInputSource(argv[1]);
            XSLTResultTarget target = new XSLTResultTarget(doc);
            processor.process(xml, xslt, target);
        }
        catch (SAXException e) {
            System.err.println("error: Error processing stylesheet.");
            System.exit(1);
        }
View Full Code Here

*
* @ant.task ignore="true"
*/
public class Xalan1Executor extends XalanExecutor {
    void execute() throws Exception {
        XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
        // need to quote otherwise it breaks because of "extra illegal tokens"
        processor.setStylesheetParam("output.dir", "'" + caller.toDir.getAbsolutePath() + "'");
        XSLTInputSource xml_src = new XSLTInputSource(caller.document);
        String system_id = caller.getStylesheetSystemId();
        XSLTInputSource xsl_src = new XSLTInputSource(system_id);
        OutputStream os = getOutputStream();
        try {
            XSLTResultTarget target = new XSLTResultTarget(os);
            processor.process(xml_src, xsl_src, target);
        } finally {
            os.close();
        }
    }
View Full Code Here

     */
    protected void transform(Node root, String xslname, String htmlname) throws SAXException {
        try{
            final long t0 = System.currentTimeMillis();
            XSLTInputSource xsl_source = getXSLStreamSource(xslname);
            XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
            File htmlfile = new File(toDir, htmlname);
            // create the directory if it does not exist
            File dir = new File(htmlfile.getParent()); // getParentFile is in JDK1.2+
            if (!dir.exists()) {
                dir.mkdirs();
            }
            task.log("Applying '" + xslname + "'. Generating '" + htmlfile + "'", Project.MSG_VERBOSE);
            processor.process( new XSLTInputSource(root), xsl_source, new XSLTResultTarget(htmlfile.getAbsolutePath()) );
            final long dt = System.currentTimeMillis() - t0;
            task.log("Transform time for " + xslname + ": " + dt + "ms");
        } catch (IOException e){
            task.log(e.getMessage(), Project.MSG_ERR);
            e.printStackTrace(); //@todo bad, change this
View Full Code Here

TOP

Related Classes of org.apache.xalan.xslt.XSLTProcessor

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.