Topic: using params in xsl IF element (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=27036" title="Pages that link to Topic: using params in xsl IF element (Page 1 of 1)" rel="nofollow" >Topic: using params in xsl IF element <span class="small">(Page 1 of 1)</span>\

 
zzqproject
Obsessive-Compulsive (I) Inmate

From:
Insane since: Nov 2005

posted posted 11-22-2005 01:14

hi, i want to evaluate the value of a parameter in an IF element, the code goes following which does not work:

+++++++++++++++++++++++++++++++++
<xslaram name="msgid" />
<xsl:for-each select="//message">
<xsl:if test="@id=$msgid">

......... processing.......

++++++++++++++++++++++++++++++++

where id is an attribute of all message element in the xml. basically i would like the code to perform certain processing when the message id = the given msgid. hav tried test="@id=[$msgid]", test="[id=$msgid]" all do not work. what should i write here?

thanks alot!

WarMage
Maniac (V) Mad Scientist

From: Rochester, New York, USA
Insane since: May 2000

posted posted 11-22-2005 16:04

In the future block out your code using the UBB code tags. It will make it easier to look at your code.

code:
<xsl:param name="msgid"/>

<xsl:for-each select="//message">
  <xsl:if test="@id=$msgid">
    ...
  </xsl:if>
</xsl:for-each>



This should do what you want. What could be happenning is that your values are not the same. Maybe you have additional white space or something in there.

Maybe try

code:
<xsl:param name="msgid"/>

<xsl:for-each select="//message">
  <xsl:choose>
    <xsl:when test="@id=$msgid">
      ...
    <xsl:when>
    <xsl:otherwise>
       <p>id's are not equal<br/>
       @id : <xsl:value-of select="@id"/>
       $msgid : <xsl:value-of select="$msgid"/></p>
    </xsl:otherwise>
  </xsl:choose>
</xsl:for-each>



Dan @ Code Town

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 11-30-2005 03:29
quote:

WarMage said:

In the future block out your code using the UBB code tags. It will make it easier to look at your code




http://www.ozoneasylum.com/27034 hehhehe

Later,

C:\



Post Reply
 
Your User Name:
Your Password:
Login Options:
 
Your Text:
Loading...
Options:


« BackwardsOnwards »

Show Forum Drop Down Menu