Jump to content

xsl param not working !


menardmam

Recommended Posts

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 finewhen i substitute 'fra' (that mean french) for the value i send with the param.... nothing... yep , just nothing come.. it lie passing nullthat line did not work! <td width="162"><div align="left"><strong><xsl:value-of select="desc[@lang=$myOrder]"/></strong></div></td>

Link to comment
Share on other sites

If you give a default value to your parameter, you'll probably notice that the problem is that the parameter is just never overriden. That is:

<xsl:param name="myOrder" select="'fra'"/>	<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>

will work, but if you try to override the parameter, you'll still get "fra". In order for a passed stylesheet parameter to work, you need to declara the parameter at the top level, outside of templates, like so:

<xsl:param name="myOrder" /><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='fra']"/></strong></div></td>	  </tr>	  </xsl:for-each>	</table>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...