Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
2.7
-
None
-
None
-
Windows 2003, JRE 1.4.
-
PatchAvailable
-
fp3
Description
If one has a style sheet that imports other style sheets which further include other style sheets and the last imported style sheet does not use a global variable it declared, XSLTC discards the variable even though it is used by other sheets. This leads to a NoSuchFieldError when the sheet is used. Following is a schematic view of the sheets. The actual sheets are in a test case.
foo.xsl:
<xsl:import href="imported/import1.xsl"/>
<xsl:import href="imported/import2.xsl"/>
<xsl:template match="bar:element">
Value of info: <xsl:value-of select="info"/>
Value of my-var from import: <xsl:call-template name="import1.xsl"/>
Value of my-var from import: <xsl:call-template name="import2.xsl"/>
</xsl:template>
imported/import1.xsl:
<xsl:include href="../inc1/inc1a.xsl"/>
<xsl:template name="import1.xsl">
From import1 my-var: <xsl:value-of select="$my-var"/>
</xsl:template>
imported/import2.xsl:
<xsl:include href="../inc1/inc1a.xsl"/>
<xsl:template name="import2.xsl">
From import2 my-var:
</xsl:template>
../inc1/inc1a.xsl
<xsl:variable name="my-var">
<Data code="Y">
<Desc>Yes</Desc>
</Data>
<Data code="N">
<Desc>No</Desc>
</Data>
</xsl:variable>
Note that imported/import2 does declares, but does not use "my-var". When run, the following trace is produced:
java.lang.NoSuchFieldError: my$dash$var
at com.gmaci.xsl.foo.import1$dot$xsl()
at com.gmaci.xsl.foo.template$dot$2()
at com.gmaci.xsl.foo.applyTemplates()
at com.gmaci.xsl.foo.applyTemplates()
at com.gmaci.xsl.foo.applyTemplates()
at com.gmaci.xsl.foo.transform()
at org.apache.xalan.xsltc.runtime.AbstractTranslet.transform(AbstractTranslet.java:593)
at org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:630)
at org.apache.xalan.xsltc.trax.TransformerImpl.transform(TransformerImpl.java:301)
at testXsl.TestDriver.doTransform(TestDriver.java:233)
at testXsl.TestDriver.main(TestDriver.java:69)
Exception in thread "main"
An obvious work-around is to ensure all global variables are used. A patch is attached. The thrust of the patch is to discard unused local variables, but not to discard any global variables.
A test case can be provided. In order to use the test case you need to add the following jars to the lib folder of the project.
xalan
jdom
serializer
resolver
xlm-apis
xercesImpl
xsltc
To run the test, execute the Ant script.