tags:

views:

38

answers:

2

Hi

I am new to xslt so please let me know whats wrong with my syntax here. If I compare with a Constant value of '880.50' I get the desired result. But if I try to do the samething with parameter being passed I get nothing. The code snippet is as under.

<xsl:template name="ShowJourneyLegs" >
  <xsl:param name="TotalFare" />  
    <Key4><xsl:value-of select='$TotalFare'/></Key4>   
    <JourneyLegKeys><xsl:value-of select="/FareSearchResponse/CompleteItineraryFares/AirFare[@Total = '880.50']/JourneyLegKeys/Key[1]"/></JourneyLegKeys>
     <JourneyLeg><xsl:value-of select="/FareSearchResponse/CompleteItineraryFares/AirFare[@Total = '$TotalFare']/JourneyLegKeys/Key[1]"/></JourneyLeg>  
</xsl:template>
+1  A: 

Remove the apostrophes from around the $TotalFare. The last XPath should look like this: /FareSearchResponse/CompleteItineraryFares/AirFare[@Total = $TotalFare]/JourneyLegKeys/Key[1]

Inside of an XPath expression, you only use apostrophes for literals.

David
Thanks. It worked :)
Abbi
A: 

I am new to xslt so please let me know whats wrong with my syntax here.

The problem is in this instruction:

<xsl:value-of select=
      "/FareSearchResponse/CompleteItineraryFares
                              /AirFare[@Total 
                                      = '$TotalFare']/JourneyLegKeys/Key[1]"/>

You are not comparing to the value of the $TotalFare but to the string '$TotalFare'.

Solution: Remove the apostrophes that surround $TotalFare.

Dimitre Novatchev
Thanks it works
Abbi