Case: I have a xsl file (Status.xsl) that includes another xsl file using <xsl include href="xsl/Attribute.xsl> I pass the Status.xsl as a value for the attribute xslt for an x:transform tag with a xsltSystemId attribute. I get a NPE javax.servlet.jsp.JspException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: java.lang.NullPointerException at org.apache.taglibs.standard.tag.common.xml.TransformSupport.doStartTag (TransformSupport.java:163) at org.apache.taglibs.standard.tag.el.xml.TransformTag.doStartTag (TransformTag.java:104) ============================================================================== The JSP Looks like: <%@taglib uri="http://java.sun.com/jstl/core" prefix="c" %> <%@taglib uri="http://java.sun.com/jstl/xml" prefix="x" %> <c:import url="/xml/listing.xml" var="xml" /> <x:parse xml="${xml}" var="xmlView" systemId="http://localhost:8080/JSTLActTrack/xml" /> <b> This JSP lists all the activities that are ... </b> <c:import url="/xml/Status.xsl" var="xsl" /> <x:transform xml="${xmlView}" xslt="${xsl}" xsltSystemId="http://localhost:8080/JSTLActTrack/xsl"> <x:param name="status" value="${param.actstat}" /> </x:transform> =========================================================== Status.xsl <?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:include href="xsl/Attribute.xsl" /> <xsl:param name ="status" select="default" /> <xsl:template match="/"> <table border="1" > <tr><th>Activity id</th><th>Resp Engr</th><th>Status</th><th>Start Date</th><th>End Date</th><th>Description</th></tr> <xsl:for-each select="//activities/activity"> <xsl:if test="status/text()=$status" > <tr> <td><xsl:value-of select="@id"/></td> <td><xsl:value-of select="resp_engr"/></td> <td><xsl:value-of select="status"/></td> <td><xsl:value-of select="start_dt"/></td> <td><xsl:value-of select="end_dt"/></td> <td><xsl:value-of select="description"/></td> </tr> </xsl:if> </xsl:for-each> </table> </xsl:template> </xsl:stylesheet> ========================================================== And Attribute .xsl looks like : <?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3c.org/1999/XSL/Transform"> <xsl:attribute-set name="color-attributes" > <xsl:attribute name="bgcolor" >cyan</xsl:attribute> </xsl:attribute-set> </xsl:stylesheet>
Apparently not a bug; I've tested and can replicated, but the RI is in compliance: - It's not an NPE but a JspException that's thrown. - The error is legitimate since the file included in the XSLT stylesheet via <xsl:include> isn't found; it's pointing to an "xsl" directory that doesn't exist, and the system IDs are off by a level in the directory hierarchy since they point to directories and not files. I've made the error message clearer; it now includes the offending file path, and it's a direct TransformerException instead of one that wraps a NullPointerException (since the latter scares people!). But this isn't a bug.
I have a file Status.xsl that refrences the file Attribute.xsl the syntax is <xsl:include href="xsl/Attribute.xsl" /> Status.xsl exists under <Context-Home>/xml/ Attribute.xsl exists under <Context-Home>/xsl/ In the JSP the code looks like : <x:transform xml="${xml}" xslt="${xslt}" xsltSystemId="http://localhost:8080/JSTLActTrack/xml" /> taking the system id one level up as is the case we resolve to http://localhost:8080/JSTLActTrack which should be fine I get this error : ======================================================================= javax.servlet.jsp.JspException: javax.xml.transform.TransformerConfigurationException: javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Had IO Exception with stylesheet file: xsl/Attribute.xsl at org.apache.taglibs.standard.tag.common.xml.TransformSupport.doStartTag (TransformSupport.java:163) at org.apache.taglibs.standard.tag.el.xml.TransformTag.doStartTag (TransformTag.java:104) at org.apache.jsp.review_0005fproj_0005fxml_0005fsysid$jsp._jspService (review_0005fproj_0005fxml_0005fsysid$jsp.java:144) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:107) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service (JspServlet.java:201) at org.apache.jasper.servlet.JspServlet.serviceJspFile (JspServlet.java:381) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:473) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (ApplicationFilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationFilterChain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperValve.java:260) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:633) at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:470) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextValve.java:191) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:633) at org.apache.catalina.valves.CertificatesValve.invoke (CertificatesValve.java:246) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:631) at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:470) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardContext.invoke (StandardContext.java:2349) at org.apache.catalina.core.StandardHostValve.invoke (StandardHostValve.java:180) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:633) at org.apache.catalina.valves.ErrorDispatcherValve.invoke (ErrorDispatcherValve.java:170) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:631) at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:171) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:631) at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:470) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineValve.java:174) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:633) at org.apache.catalina.valves.AccessLogValve.invoke (AccessLogValve.java:469) at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNex t(StandardPipeline.java:631) at org.apache.catalina.core.StandardPipeline.invoke (StandardPipeline.java:470) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995) at org.apache.coyote.tomcat4.CoyoteAdapter.service (CoyoteAdapter.java:223) at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java:405) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnectio n(Http11Protocol.java:358) at org.apache.tomcat.util.net.TcpWorkerThread.runIt (PoolTcpEndpoint.java:495) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run (ThreadPool.java:518) at java.lang.Thread.run(Thread.java:536) --------------------------------------------------------------------------------
Okay, I've tracked down the underlying bug. The present code for TransformSupport is now a masterpiece of case analysis :-) -- if there are still cases that aren't accounted for, I'll be disappointed!