I'm trying to do an Xalan XSLT Transformation inside a portlet in order to
transform an XML DOM Element (which I've received from a web service) into
html to display. When the last line in the following code gets executed -
which doesn't do the transform but merely creates the transformer - I'm
getting this Exception:
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException:
java.lang.NullPointerException at
org.apache.xalan.processor.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.java:816)
at com.mycompany.portlets.dql.HelloWorld.service
here's the code:
InputStream xsltStream =
context.getResourceAsStream("/WEB-INF/hardcode.xsl");
xsltStreamSource = new StreamSource(xsltStream);
TransformerFactory tFactory = TransformerFactory.newInstance();
try {
Transformer transformer = tFactory.newTransformer(xsltStreamSource);
outputString = "transformer created";
}
catch (TransformerConfigurationException tce) {
PrintWriter writer = response.getWriter();
tce.printStackTrace(writer);
}
I verified that the XSL file is being read properly and converted into an
InputStream. I even went so far as to hardcode the XSL into my portlet and
read it in from a StringReader - same result.
Many thanks for any help offered.
- Dave Levitt
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list