Variables and Parameters in SAXON

Subject: Variables and Parameters in SAXON
From: Scott Sanders <scott@xxxxxxxxxxxx>
Date: Fri, 17 Dec 1999 12:49:01 -0700
Title: 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" xmlns:xsl="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

Current Thread