This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Losing top-level parameters when moving from Xalan-J 1.2.d01 to 1.2.0
- To: xalan-dev at xml dot apache dot org, xsl-list at mulberrytech dot com
- Subject: Losing top-level parameters when moving from Xalan-J 1.2.d01 to 1.2.0
- From: Charles Douthart <Charles dot Douthart at Trifolium dot com>
- Date: Wed, 1 Nov 2000 18:19:25 -0400 (EST)
- Reply-To: xsl-list at mulberrytech dot com
I'm currently trying to upgrade our XSL components from Xalan1.2.D01 to
Xalan1.2.0 and have encountered a problem with paramters. It appears
that top-level paramters are no longer visible to the XSL processor.
the code that handles most of the processing is as follows:
// Chaned to liason for Xerces 1.2.0
XSLTProcessor processor =
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor(new
org.apache.xalan.xpath.xdom.XercesLiaison());
XSLTInputSource xmlSource = new XSLTInputSource(doc); // doc is an
org.w3c.dom.Document
XSLTInputSource xslSource = new XSLTInputSource(transformName);
Iterator keys = rendererProperties.keySet().iterator();
System.out.println("XSL Processor Paramters:");
while (keys.hasNext())
{
String key = (String)keys.next();
String value = (String)rendererProperties.get(key);
System.out.println("\t" + key + ": " + value);
processor.setStylesheetParam(key, value);
}
processor.process(xmlSource, xslSource,new
XSLTResultTarget(httpResponse.getWriter()));
And the transformation is:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
Note: These parameters are defined in another file and included using
<xsl:include href="stdparams.xsl"/>
<xsl:param name = "NAVIGATION_ROOT" select = "'root'"/>
<xsl:param name = "SERVLET_PATH" select = "'null'"/>
<xsl:param name = "CONTEXT_PATH" select = "'null'"/>
<xsl:variable name = "FULL_SERVLET_PATH" select =
"concat($CONTEXT_PATH,$SERVLET_PATH)"/>
<xsl:variable name = "SERVLET_NAME" select =
"substring($SERVLET_PATH,2)"/>
<xsl:template match="/">
<HTML>
<HEAD>
... header here
</HEAD>
<BODY >
... body here
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
This transformation is applied to a _very_ simple, valid document that is
constructed from an in-memory string. All ran well under D01, but after
changing to 1.2.0, I get the following output:
XSL Processor Paramters:
NAVIGATION_ROOT: 'undefined'
CONTEXT_PATH: '/ctx'
SERVLET_PATH: '/Main'
XSL Error: pattern = 'substring($SERVLET_PATH,2)'
VariableReference given for variable out of context or without
definition! Name = SERVLET_PATH, source tree node: #document
XSL Error: SAX Exception
org.apache.xalan.xslt.XSLProcessorException: pattern =
'substring($SERVLET_PATH,2)'
VariableReference given for variable out of context or without
definition! Name = SERVLET_PATH
at java.lang.Throwable.<init>(Throwable.java:96)
at java.lang.Exception.<init>(Exception.java:44)
at org.xml.sax.SAXException.<init>(SAXException.java:38)
Any idea what is happening to my parameters?
TIA,
Charles Douthart
Trifolium, inc
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list