Topic: using params in xsl IF element Pages that link to <a href="https://ozoneasylum.com/backlink?for=27036" title="Pages that link to Topic: using params in xsl IF element" rel="nofollow" >Topic: using params in xsl IF element\

 
Author Thread
zzqproject
Obsessive-Compulsive (I) Inmate

From:
Insane since: Nov 2005

IP logged posted posted 11-22-2005 01:14 Edit Quote

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

IP logged posted posted 11-22-2005 16:04 Edit Quote

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

IP logged posted posted 11-30-2005 03:29 Edit Quote
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