开发者

How to use parameter variable in xslt

开发者 https://www.devze.com 2023-01-03 09:13 出处:网络
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

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/CompleteItine开发者_Go百科raryFares/AirFare[@Total = '880.50']/JourneyLegKeys/Key[1]"/></JourneyLegKeys>
     <JourneyLeg><xsl:value-of select="/FareSearchResponse/CompleteItineraryFares/AirFare[@Total = '$TotalFare']/JourneyLegKeys/Key[1]"/></JourneyLeg>  
</xsl:template>


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消