1

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>
2
  • You need to format your code by indenting it with 4 spaces or it will not display correctly. Commented Jun 15, 2010 at 22:13
  • Good Question (+1). See my answer for an explanation and solution of the problem. :) Commented Jun 15, 2010 at 22:29

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.