title: Use XSLT to find node and specific attribute value
body: <p>This is an example of my xml code:</p>
  
  <pre><code>&lt;db&gt;
    &lt;group&gt;
    &lt;name&gt;Team1&lt;/name&gt;
      &lt;set num="1"&gt;AAA&lt;/set&gt;
      &lt;set num="2"&gt;BBB&lt;/set&gt;
      &lt;set num="3"&gt;CCC&lt;/set&gt;
    &lt;/group&gt;
    &lt;group&gt;
    &lt;name&gt;Team2&lt;/name&gt;
      &lt;set num="1"&gt;DDD&lt;/set&gt;
      &lt;set num="2"&gt;AAA&lt;/set&gt;
      &lt;set num="3"&gt;FFF&lt;/set&gt;
      &lt;set num="4"&gt;EEE&lt;/set&gt;
    &lt;/group&gt;
    &lt;group&gt;
    &lt;name&gt;Team3&lt;/name&gt;
      &lt;set num="1"&gt;AAA&lt;/set&gt;
      &lt;set num="2"&gt;GGG&lt;/set&gt;
      &lt;set num="3"&gt;FFF&lt;/set&gt;
    &lt;/group&gt;
    &lt;group&gt;
    &lt;name&gt;Team4&lt;/name&gt;
      &lt;set num="1"&gt;BBB&lt;/set&gt;
      &lt;set num="2"&gt;EEE&lt;/set&gt;
      &lt;set num="3"&gt;AAA&lt;/set&gt;
    &lt;/group&gt;
  &lt;/db&gt;
  </code></pre>
  
  <p>How would I use xslt to display the name and num of all instances where AAA has a num less than 3, so my output would look something like this:</p>
  
  <pre><code>&lt;result value="AAA"&gt;
    &lt;name num="1"&gt;Team1&lt;/name&gt;
    &lt;name num="2"&gt;Team2&lt;/name&gt;
    &lt;name num="1"&gt;Team3&lt;/name&gt;
  &lt;/result&gt;
  </code></pre>
  
  <p>The code I have been trying to use is as follows:</p>
  
  <pre><code>...
  &lt;xsl:template match="/db"&gt;
    &lt;result value="AAA"&gt;
      &lt;xsl:for-each select="group[set/@num &amp;lt; '3' and set='AAA']"&gt;
        &lt;name num="{@num}"&gt;
          &lt;xsl:value-of select="name" /&gt;
        &lt;/name&gt;
      &lt;/xsl:for-each&gt;
    &lt;/result&gt;
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>But this give me all groups that contain "AAA" regardless of num, and the num always displays as "" no matter what. </p>
  
  <p>Any help would be appreciated as I am new to XSLT.
  Thanks!</p>