Z
z-man
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.Param
at
com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable.addVariable(SymbolTable.java:79)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Variable.parseContents(Variable.java:86)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseOwnChildren(Stylesheet.java:580)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseContents(Stylesheet.java:562)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Import.parseContents(Import.java:115)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseOwnChildren(Stylesheet.java:590)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseContents(Stylesheet.java:562)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Parser.java:380)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:325)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:410)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:791)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.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:xsl="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"<xslaram name="sourcePath">
<!-- Data source absolute path. -->
</xslaram>
<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}"/>
....
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.Param
at
com.sun.org.apache.xalan.internal.xsltc.compiler.SymbolTable.addVariable(SymbolTable.java:79)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Variable.parseContents(Variable.java:86)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseOwnChildren(Stylesheet.java:580)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseContents(Stylesheet.java:562)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Import.parseContents(Import.java:115)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseOwnChildren(Stylesheet.java:590)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Stylesheet.parseContents(Stylesheet.java:562)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.Parser.createAST(Parser.java:380)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:325)
at
com.sun.org.apache.xalan.internal.xsltc.compiler.XSLTC.compile(XSLTC.java:410)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:791)
at
com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl.newTransformer(TransformerFactoryImpl.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:xsl="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"<xslaram name="sourcePath">
<!-- Data source absolute path. -->
</xslaram>
<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}"/>
....