[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Resetting Parameters
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 keyfunction 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>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|