RE: Variables and Parameters in SAXON

Subject: RE: Variables and Parameters in SAXON
From: Kay Michael <Michael.Kay@xxxxxxx>
Date: Mon, 20 Dec 1999 13:24:16 -0000
This is a known error in version 5.0, global variables do not work if a
default namespace is declared on the xsl:stylesheet element.
 
Mike Kay

-----Original Message-----
From: Scott Sanders [mailto:scott@xxxxxxxxxxxx]
Sent: 17 December 1999 19:49
To: 'xsl-list@xxxxxxxxxxxxxxxx'
Subject: Variables and Parameters in SAXON



I have an XML document and a stylesheet that used to work with SAXON 4.x,
but after having upgraded to 5.0, it fails with the error variable 'xxx' not
defined.  Is this some type of scoping issue?  If it is, how do I reference
a top level variable, or a parameter that I am passing in from a servlet?

test.xml: 
<?xml version="1.0"?> 
<screen title="titletest"> 
        <search type="searchtest"/> 
</screen> 

test.xsl: 
<?xml version="1.0"?> 
<xsl:stylesheet version="1.0" xmlns=" http://www.w3.org/TR/REC-html40
<http://www.w3.org/TR/REC-html40> " xmlns:xsl="
http://www.w3.org/1999/XSL/Transform <http://www.w3.org/1999/XSL/Transform>
"> 

<xsl:output method="html"/> 
<xsl:variable name="testvar">TESTING</xsl:variable> 
<xsl:param name="search"/> 

<xsl:template match="screen"> 
<html> 
<head> 
<title>Testing <xsl:value-of select="@title"/></title> 
</head> 
<body> 
<h1 class="title"><xsl:value-of select="@title"/></h1> 
<xsl:apply-templates/> 
</body> 
</html> 
</xsl:template> 

<xsl:template match="search"> 
<h2>This is a test<xsl:value-of select="$testvar"/></h2> 
</xsl:template> <!--search--> 
</xsl:stylesheet> 

When I run the following: 
java com.icl.saxon.StyleSheet test.xml test.xsl >test.html 

I get the following error: 
Error preparing style sheet 
At xsl:value-of on line 21 of file:/D:/web/content/xmldocs/test.xsl:
Variable testvar has not been declared 

Can anyone help? 

TIA, 
Scott Sanders 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread