Bug 11293

Summary: NullPointerError when importing an xsl sheet from an already imported one
Product: Taglibs Reporter: Kit Westneat <cwestnea>
Component: Standard TaglibAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P3    
Version: 1.0   
Target Milestone: ---   
Hardware: PC   
OS: other   

Description Kit Westneat 2002-07-30 14:48:04 UTC
The XSLT processor throws a NullPointerError when importing a styeesheet from
another stylesheet that is imported from a stylesheet that is being used by
<x:transform>, but does not throw one from the command line. For example, I have
3 xsl sheets, page1.xsl, page2.xsl, and page3.xsl. 

page1 is like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="page2.xsl" />

<xsl:template match="/">
	<xsl:call-template name="do-something" />
</xsl:template>
</xsl:stylesheet>

page2 is like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="page3.xsl" />

<xsl:template name="do-something">
	<xsl:call-template name="do-another-thing" />
</xsl:template>
</xsl:stylesheet>

page3 is like:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template name="do-another-thing">
	another thing
</xsl:template>
</xsl:stylesheet>

and the jsp is:
<%@ taglib prefix="x" uri="http://java.sun.com/jstl/xml" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>

<c:import url="page1.xsl" var="xsl" />
<x:transform xslt="${xsl}">
<?xml version="1.0" encoding="ISO-8859-1"?>
<doc>
	<test>test</test>
</doc>
</x:transform>

The result is:
javax.servlet.ServletException:
javax.xml.transform.TransformerConfigurationException:
javax.xml.transform.TransformerException: java.lang.NullPointerException
	at
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:490)
	at org.apache.jsp.test2$jsp._jspService(test2$jsp.java:114)
	at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:136)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
...
etc

if I change page2 to be:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<!-- xsl:import href="page3.xsl" / -->

<xsl:template name="do-something">
	<xsl:call-template name="do-another-thing" />
</xsl:template>

<xsl:template name="do-another-thing">
	another thing
</xsl:template>
</xsl:stylesheet>

it works.
Comment 1 Shawn Bayern 2002-07-30 15:16:56 UTC
It's not absolutely clear to me that this is a bug against the JSTL 1.0 
specification, but in the interest of what seems like appropriate 
functionality, I have adjusted the RI code to allow your examples to work.  
Thanks for the report.