Hello all
I'm trying to run an XSLT transformation using JDK 1.5.0, but I get an
exception (see below).
The strange thing is that using the *same* code & stylesheet on JDK 1.4,
it works!
Specifically, when I invoke a new transformer
(TransformerFactory.newInstance().newTransformer(. ..)) xalan cries that
it can't compile the stylesheet because a parameter of its is undefined
(you guess: how could I set a parameter *before* instantiating the
corresponding transformer?! It's a proverbial matter of chicken & egg...)!
Many thanks for your suggestions!
***** Here it is the call stack:
java.lang.ClassCastException:
com.sun.org.apache.xalan.internal.xsltc.compiler.P aram
at
com.sun.org.apache.xalan.internal.xsltc.compiler.S ymbolTable.addVariable(SymbolTable.java:79)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.V ariable.parseContents(Variable.java:86)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.S tylesheet.parseOwnChildren(Stylesheet.java:580)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.S tylesheet.parseContents(Stylesheet.java:562)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.I mport.parseContents(Import.java:115)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.S tylesheet.parseOwnChildren(Stylesheet.java:590)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.S tylesheet.parseContents(Stylesheet.java:562)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.P arser.createAST(Parser.java:380)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.X SLTC.compile(XSLTC.java:325)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.X SLTC.compile(XSLTC.java:410)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTemplates(TransformerFactoryI mpl.java:791)
at
com.sun.org.apache.xalan.internal.xsltc.trax.Trans formerFactoryImpl.newTransformer(TransformerFactor yImpl.java:619)
at mine.PageBuilder.main(PageBuilder.java:89)
ERROR: 'file:///home/xyz/styles/page.teg.xhtml.xsl: line 56: Variable
or parameter 'site' is undefined.'
FATAL ERROR: 'Could not compile stylesheet'
***** Here they are the affected mine.PageBuilder.main() lines of code:
File stylesheet = ... // That's OK.
Transformer transformer = null;
try
{
transformer = TransformerFactory.newInstance().newTransformer(
new StreamSource(stylesheet.getCanonicalPath())
);
}
catch(Exception exception)
{
printError(exception); // Here it is where my exception is trapped
(sob!).
}
transformer.setParameter("sourcePath", this.sourcePath); // Here it is
where I should define (god willing...) my stylesheet param (just *after*
the /failed/ creation of the transformer).
***** Here it is the stylesheet
(file:///home/xyz/styles/page.teg.xhtml.xsl) that xalan cannot compile:
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet
xmlns

sl="http://www.w3.org/1999/XSL/Transform"
xmlns:teg="http://www.something.com/tegumento"
xmlns="http://www.w3.org/1999/xhtml"
xmlns:html="http://www.w3.org/1999/xhtml"
exclude-result-prefixes="teg teg-ext html"
version="1.0"
>
<xsl

aram name="sourcePath">
<!-- Data source absolute path. -->
</xsl

aram>
<xsl:variable name="site" select="document(concat($sourcePath,
'site.teg'))/teg:site"/>
....
<!-- This is the line 56 that raises the error "Variable or parameter
'site' is undefined.' FATAL ERROR: 'Could not compile stylesheet'" -->
<meta name="keywords" content="{$site/teg:info/teg:keywords},
{teg:info/teg:keywords}"/>
....