Use of global variable and parameter

Subject: Use of global variable and parameter
From: "Vivek Shinde" <Vivek.Shinde@xxxxxxx>
Date: Fri, 4 Jun 2004 00:29:12 -0400
Hi,

I have first XSL as follows: 

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
	<xsl:output method="html"/>

	<xsl:variable name="forcountry" select="GB"/>
	<xsl:include href="secondxsl.xsl"/>

</xsl:stylesheet>

Then withing secondxsl.xsl I am using a variable 'forcountry' within one of the template as:

<?xml version="1.0" encoding="UTF-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
	<xsl:output method="html"/>

<xsl:template match="article" mode="details-introduction">
<xsl:if test="metadata[countryname=$forcountry]">
..........
..........
</xsl:if>
</xsl:template>
</xsl:stylesheet>

But, it seems that the value of forcountry is blank within secondxsl.xsl.
I understand that the global variable definition works only within a stylesheet (I tried defining xsl:variable within the secondxsl.xsl right after xsl:output and it still does not work). But in Michael Kay's book 'XSLT 2nd edition' on page 83 it states 'Global parameters are set from outside the stylesheet' (last paragraph), so I tried changing 'xsl:variable' to 'xsl:param' and it still does not work.

Any help please?
Thanks
Vivek

Current Thread