Forum Moderators: open
You need to get the variable the same way you would get it via coldfusion, then set it in xslt.
so,
[code]
<xsl:variable name="product">
... put the cold fusion code to extract the url parameter here
</xsl:variable>
<xsl:if test="$product='ice'">
...do something
</xsl:if>
<xsl:template match="<cfoutput>#URL.prodottoID#</cfoutput>">
<div id="Scheda">
<div class="intestazione">
<img src="{scheda/intestazione/logo}" class="iileft"></img>
<h2><xsl:value-of select="scheda/intestazione/prodotto"/></h2>
<h3><xsl:value-of select="scheda/intestazione/titolo"/></h3>
<span><xsl:value-of select="scheda/intestazione/dosaggio"/></span>
<h3><img src="/dulcis/img/confezione.gif" width="43" height="35" />
<xsl:value-of select="scheda/intestazione/confezione"/></h3>
</div>
<div class="line"><img src="../../img/clear.gif" alt="" /></div>
<div class="preparazione"><xsl:value-of select="scheda/titolo"/></div>
<xsl:for-each select="scheda/preparazione/fase">
<div class="fasi"><img src="{img}" class="iileft"></img>
<span><xsl:value-of select="descr"/></span>
</div>
<div class="line"><img src="../../img/clear.gif" alt="" /></div>
</xsl:for-each>
</div>
</xsl:template>
</xsl:template>
</xsl:stylesheet>
test.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<products>
<product id='1'>
<name>wid</name>
</product>
<product id='2'>
<name>git</name>
</product>
</products>
test.xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="productId" select="0" />
<xsl:template match="/">
<!-- display the product info based on what was passed to us -->
<xsl:text>Here is the name of product #</xsl:text><xsl:value-of select="$productId"/><xsl:text>-</xsl:text>
<xsl:value-of select="products/product[@id=$productId]/name" />
</xsl:template>
</xsl:stylesheet>
test.cfml
<cffile action="read" file="/Users/paul/Applications/ColdFusionMX7/wwwroot/test.xsl" variable="xmltrans">
<cfset xmldoc = XmlParse("/Users/paul/Applications/ColdFusionMX7/wwwroot/test.xml")>
<cfset productId = #Url.productId#>
<cfscript>
variables.theXslParams = StructNew();
StructInsert(variables.theXslParams, "productId", productId);
WriteOutput(XmlTransform(xmldoc, xmltrans, variables.theXslParams));
</cfscript>
then call test.cfml. i hope this works. if not, sticky me and we'll work it out then post the solution.
<cfinvoke component="component.content_menu" method="Content" returnvariable="xmlcontent" xmlFile="prodotti_#session.lang#" prodottoID="#URL.prodottoID#" xslFile="scheda" xPath="D:\Inetpub\#*$!xxx\xml_files\">
<cfoutput>#xmlContent#</cfoutput>
<cffunction name="Content" access="public" returntype="string">
<cfargument name="xmlFile" type="string" required="yes">
<cfargument name="xslFile" type="string" required="yes">
<cfargument name="xPath" type="string" required="yes">
<cfargument name="prodottoID" type="string" required="no">
<cffile action="read" file="#xPath##xmlFile#.xml" variable="xmldoc">
<cffile action="read" file="#xPath##xslFile#.xsl" variable="xsldoc">
<cfset xmlDoc= XmlParse(xmldoc)>
<cfset xmlTranslation = XmlParse(xsldoc)>
<cfif isDefined("prodottoID")>
<cfscript>
variables.theXslParams = StructNew();
StructInsert(variables.theXslParams, "prodottoId", prodottoId);
</cfscript>
<cfset xmlContent=XmlTransform(xmldoc, xsldoc, variables.theXslParams)>
<cfelse>
<cfset xmlContent = XmlTransform(xmlDoc,xmlTranslation) >
</cfif>
<cfreturn xmlContent >
</cffunction>
my xsl
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="prodottoID" />
<xsl:template match="/">
<xsl:value-of select="$prodottoID"/>
<div id="Scheda">
<div class="intestazione">
<img src="{dessert/scheda[@id=$prodottoID]/intestazione/logo}" class="iileft"></img>
<h2><xsl:value-of select="dessert/scheda[@id=$prodottoID]/intestazione/prodotto"/></h2>
<h3><xsl:value-of select="dessert/scheda[@id=$prodottoID]/intestazione/titolo"/></h3>
<span><xsl:value-of select="dessert/scheda[@id=$prodottoID]/intestazione/dosaggio"/></span>
<h3><img src="/dulcis/img/confezione.gif" width="43" height="35" />
<xsl:value-of select="dessert/scheda[@id=$prodottoID]/intestazione/confezione"/></h3>
</div>
<div class="line"><img src="../../img/clear.gif" alt="" /></div>
<div class="preparazione"><xsl:value-of select="dessert/scheda[@id=$prodottoID]/titolo"/></div>
<xsl:for-each select="dessert/scheda[@id=$prodottoID]/preparazione/fase">
<div class="fasi"><img src="{img}" class="iileft"></img>
<span><xsl:value-of select="descr"/></span>
</div>
<div class="line"><img src="../../img/clear.gif" alt="" /></div>
</xsl:for-each>
</div>