Basically, I copied the JAXPTransletMultipleTransformations code from
the Xalan samples. When loading the XSL and creating the Templates
object, everything is fine, but when I attempt to create a Transformer
from the Templates instance, I receive a
TransformerConfigurationException. The same XSL works fine when I do not
use the xsltc.trax.TransformerFactoryImpl as the default
TransformerFactory.
I looked at the code, and am confused by what could be going wrong. I
tried compiling the XSL from the command line, and the appropriate class
was generated. All of the xalan/bin/*.jar files are placed in my WEB-
INF/lib directory within my WAR file. Could it be that the
TransletClassLoader does not work within the context of a WAR file? Or
am I doing something fundamentally wrong here.
TIA for any clues.
enc: Random pseudo-relevant data
In my class constructor I am doing:
final String xsltcTransformerClass =
"org.apache.xalan.xsltc.trax.TransformerFactoryImpl";
try {
Class.forName(xsltcTransformerClass);
}
catch (Exception e) {
Category.getInstance("org.titanomachia.servlet.view").error("Problem
loading " +
xsltcTransformerClass, e);
throw new ServletException(e.getMessage());
}
java.util.Properties p = System.getProperties();
p.put("javax.xml.transform.TransformerFactory",
xsltcTransformerClass);
System.setProperties(p);
try {
TransformerFactory factory = TransformerFactory.newInstance();
templates = factory.newTemplates(new StreamSource(xslURI));
}
catch (Exception e) {
Category.getInstance("org.titanomachia.servlet.view").error(
"Problems constructing Translet from XSL file, attempt to use
interpretive mode.", e);
throw new ServletException(e.getMessage());
}
And later, I am doing:
try {
Transformer t = templates.newTransformer();
t.transform(new DOMSource(view),
new StreamResult(response.getOutputStream()));
}
catch (TransformerException te) {
Category.getInstance("org.titanomachia.servlet.view").error(
"Error transforming XML document.", te);
throw new ServletException(te.getMessage());
}
I received the following exception:
2001-08-22 14:42:42,063: org.titanomachia.servlet.view ERROR
(CompiledTranslator
.java:175) - Error transforming XML document.
javax.xml.transform.TransformerConfigurationException: This template
does not co
ntain a valid translet class definition.
at
org.apache.xalan.xsltc.trax.TemplatesImpl.newTransformer(TemplatesImp
l.java:199)
at
org.titanomachia.servlet.view.CompiledTranslator.processView(Compiled
Translator.java:170)
at
org.titanomachia.servlet.view.Renderer.handleEvent(Renderer.java:203)