[xsl] run time error "TransformerFactoryConfigurationError"

Subject: [xsl] run time error "TransformerFactoryConfigurationError"
From: Yongxia Yan <yyan@xxxxxxxxx>
Date: Thu, 25 Mar 2004 10:20:14 -0700
All,

I am newbie to xml and tried to run the examples on apache site. I installed the following jars to my box:
xalan.jar/xml-apis.jar/xercesImpl.jar and set my classpath according. The compile is ok, but got a run time error.

Any idea?

Thanks.

Yongxia

-----------------------------------------------------------------Error-------------------------------------------------

Exception in thread "main" javax.xml.transform.TransformerFactoryConfigurationError: Provider
org.apache.xalan.xsltc.trax.TransformerFactoryImpl not found
        at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java:100)
        at JAXPTransletMultipleTransformations.main(JAXPTransletMultipleTransformations.java:71)



-----------------------------------------------------------------Code-------------------------------------------------
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

import java.util.Properties;

import javax.xml.transform.Templates;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamSource;


/**
 * Using the TrAX/JAXP 1.1 interface to compile a translet and use it
 * to perform multiple transformations. The translet implements
 * the Templates interface. If you want to use the translet to perform a
 * single transformation, see JAXPTransletOneTransformation.java.
 *
 *
 * @author Donald Leslie
 */
public class JAXPTransletMultipleTransformations
{
 static void doTransform(Templates translet, String xmlInURI, String htmlOutURI)
        throws TransformerException, FileNotFoundException
  {
    // For each transformation, instantiate a new Transformer, and perform
    // the transformation from a StreamSource to a StreamResult;
    Transformer transformer = translet.newTransformer();
    transformer.transform( new StreamSource(xmlInURI),
                           new StreamResult(new FileOutputStream(htmlOutURI)));
  }

  public static void main(String argv[])
  {
    // Set the TransformerFactory system property to generate and use translets.
    // Note: To make this sample more flexible, load properties from a properties file.
    // The setting for the Xalan Transformer is "org.apache.xalan.processor.TransformerFactoryImpl"
    String key = "javax.xml.transform.TransformerFactory";
    String value = "org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
    Properties props = System.getProperties();
    props.put(key, value);

    System.setProperties(props);

    String xslInURI = "todo.xsl";

    try
    {
      // Instantiate the TransformerFactory, and use it along with a SteamSource
      // XSL stylesheet to create a translet as a Templates object.
      TransformerFactory tFactory = TransformerFactory.newInstance();
      Templates translet = tFactory.newTemplates(new StreamSource(xslInURI));

      // Perform each transformation
      doTransform(translet, "todo.xml", "todo.html");
      System.out.println("Produced todo.html");

      doTransform(translet, "todotoo.xml", "todotoo.html");
      System.out.println("Produced todotoo.html");
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
  }
}

Current Thread