How to use both <(lessthan) and > (greater than) in template match

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • njsimha
    New Member
    • Sep 2008
    • 17

    How to use both <(lessthan) and > (greater than) in template match

    Hi,
    In the following XML snippet,the output has to select all the <template1>ta gs whose <subelem1> value is > 50 and <100


    Code:
    <root>
    
    <template1>
    <elem1>
       <subelem1>45</subelem1>
    </elem1>
     </template1>
    
    <template1>
    <elem1>
       <subelem1>55</subelem1>
    </elem1>
     </template1>
    
    <template1>
    <elem1>
       <subelem1>65</subelem1>
    </elem1>
     </template1>
    
    <template1>
    <elem1>
       <subelem1>75</subelem1>
    </elem1>
     </template1>
    
    </root>
    I used the following code to select all the <template1> which has <subemel1> value greater than 50 and lessthan 100:

    <xsl:template match="/root/template1[elem1/subelem1 &gt; 50 and &lt 100] ">
    .....
    .....


    but this is not working.Please reply me how to solve the above problem?

    Thanks,
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    your second condition is inclomplete, do either
    Code:
    <xsl:template match="/root/template1[elem1/subelem1 &amp;gt; 50 and [b]elem1/subelem1[/b] &lt 100] ">
    // or
    <xsl:template match="/root/template1[elem1/subelem1 &amp;gt; 50][elem1/subelem1 &lt 100]">
    regards

    Comment

    • njsimha
      New Member
      • Sep 2008
      • 17

      #3
      Hi Dormilich,
      Thanks a lot!! Its working
      Actually I am a newbie in XSLT and all your tips are very helpful for me to learn.

      Originally posted by Dormilich
      your second condition is inclomplete, do either
      Code:
      <xsl:template match="/root/template1[elem1/subelem1 &amp;gt; 50 and [b]elem1/subelem1[/b] &lt 100] ">
      // or
      <xsl:template match="/root/template1[elem1/subelem1 &amp;gt; 50][elem1/subelem1 &lt 100]">
      regards

      Comment

      Working...