PDA

View Full Version : xsl param not working


menardmam
02-04-2008, 05:18 AM
here is my little code


<?xml version="1.0" encoding="ISO-8859-1"?><!-- DWXMLSource="listedeprix.xml" -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:template match="/">
<xsl:param name="myOrder" />

<table cellspacing="0" class="tableclass">
<xsl:for-each select="pricelist/item">
<tr>
<td width="162"><div align="left"><strong><xsl:value-of select="desc[@lang='fra']"/></strong></div></td>
</tr>
</xsl:for-each>
</table>


at this line :
<td width="162"><div align="left"><strong><xsl:value-of select="desc[@lang='fra']"/></strong></div></td>

it work fine

when i substitute 'fra' (that mean french) for the value i send with the param.... nothing... yep , just nothing come.. it lie passing null

that line did not work!
<td width="162"><div align="left"><strong><xsl:value-of select="desc[@lang=$myOrder]"/></strong></div></td>

oesxyl
02-04-2008, 05:27 AM
if you want to use myOrder as a global parameter to your stylesheet you must put it in front of your file. The way you use it now have local scope to your template.


<?xml version="1.0" encoding="ISO-8859-1"?><!-- DWXMLSource="listedeprix.xml" -->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:param name="myOrder" />

<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:template match="/">
<table cellspacing="0" class="tableclass">
<xsl:for-each select="pricelist/item">
<tr>
<td width="162">
<div align="left">
<strong>
<xsl:value-of select="desc[@lang = $myOrder]"/>
</strong>
</div>
</td>
</tr>
</xsl:for-each>
</table>


best regards

menardmam
02-06-2008, 09:19 PM
I figure it out myself after 2 hours searching...

Thanks anyway for your help... maybe it can help somebody searching