[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Resetting Parameters


Subject: [xsl] Resetting Parameters
From: "Shane Sawyer" <shanesawyer@xxxxxxxxxxx>
Date: Wed, 09 Apr 2003 09:26:17 +0000

What I'm trying to do is pick up a value i.e. (Environment) from the start of my XML File and use that value in another template.

Basically in development terms I'm trying to create a Global variable with can be reset and used anywhere in the script.

In the following example I trying to pick up the value from the Environment Element and store it in the Parameter EnvironmentParam and then in the ProductType template output the new value held in the EnvironmentParam parameter.

From an earlier post I read it sounded like maybe I could use the key
function to do this but I could not get it to work using that eiter.

Thanks Shane.

My sample script and xml below:

************* XSLT File *************
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
xmlns:msxml="urn:schemas-microsoft-com:xslt">


<xsl:param name="EnvironmentParam" select=" 'DefaultEnvironment' "/>

	<xsl:template name="RootTemplate" match="/">
		<xsl:apply-templates select="Environment"/>
		<xsl:apply-templates/>
	</xsl:template>


<xsl:template name="ProductTypeTemplate" match="ProductType">
<ProductType>
<EnvironmentParam><xsl:value-of select="$EnvironmentParam"/></EnvironmentParam>
<SystemType><xsl:value-of select="SystemType"/></SystemType>
<SystemID><xsl:value-of select="SystemID"/></SystemID>
</ProductType>
</xsl:template>


	<xsl:template name="EnvironmentTemplate" match="Environment">
		<xsl:param name="TheEnvironmentParam" select="."/>
	</xsl:template>

</xsl:stylesheet>


************* XML File *************
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="C:\Dev\XSLTest\TestFiles\COMTestWithParam.xsl"?>
<Request>
<Environment>NewEnvironment</Environment>
<ProductTypes>
<ProductType>
<SystemType>AB</SystemType>
<SystemID>A</SystemID>
<TypeDescription>System ID1</TypeDescription>
</ProductType>
<ProductType>
<SystemType>AB</SystemType>
<SystemID>A</SystemID>
<TypeDescription>System ID2</TypeDescription>
</ProductType>
</ProductTypes>
</Request>



_________________________________________________________________ Express yourself with cool emoticons http://www.msn.co.uk/messenger


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




Current Thread
Keywords