title: How to apply filter across two templates
body: <p>In another thread another developer helped me by providing the awesome answer below. </p>
  
  <p>Basically two templates are used to retrieve all of the data I need to present in my table. </p>
  
  <p>My question now is how do I now apply a filter that will filter to both templates? I can successfully use <code>xsl:value-of select="@Name[contains(.,NameIWant1)]"</code> in the <code>xsl:template match="SubGroup"</code> but I cant figure out how to get it applied to <code>xsl:template match="Data"</code>. I tried to use various name ways to no avail.  </p>
  
  <p>Thanks in advance you guys have been a huge help in me learnig XSLT!! kg</p>
  
  <p>Sample XML</p>
  
  <pre><code>&lt;?xml-stylesheet type="text/xsl" href="Sample.xsl"?&gt;
  &lt;DataView Client="Client1" ID="1000" TimeStamp="12/7/2011 5:35:09 PM"&gt;
  &lt;Group ID="5000" Name="GroupName1"&gt;
  &lt;SubGroup ID="7000" Order="0" Name="NameIWant1"&gt;
  &lt;Data ID="1" Name="DataName1" Order="0"&gt;1&lt;/Data&gt;
  &lt;Data ID="2" Name="DataName2" Order="0"&gt;2&lt;/Data&gt;
  &lt;Data ID="3" Name="DataName3" Order="0"&gt;3&lt;/Data&gt;
  &lt;Data ID="12" Name="DataName4" Order="0"&gt;4&lt;/Data&gt;
  &lt;/SubGroup&gt;
  &lt;SubGroup ID="8000" Order="0" Name="NameIWant2"&gt;
  &lt;Data ID="1" Name="DataName1" Order="0"&gt;6&lt;/Data&gt;
  &lt;Data ID="2" Name="DataName2" Order="0"&gt;7&lt;/Data&gt;
  &lt;Data ID="3" Name="DataName3" Order="0"&gt;8&lt;/Data&gt;
  &lt;Data ID="12" Name="DataName4" Order="0"&gt;9&lt;/Data&gt;
  &lt;/SubGroup&gt;
  &lt;/Group&gt;
  &lt;/DataView&gt; 
  </code></pre>
  
  <p><code>Sample.xslt</code>:</p>
  
  <pre><code>&lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
      &lt;xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/&gt;
      &lt;xsl:strip-space elements="*"/&gt;
      &lt;xsl:template match="/"&gt;
          &lt;html&gt;
              &lt;body&gt;
                  &lt;h2&gt;My Data&lt;/h2&gt;
                  &lt;table border="1"&gt;
                      &lt;tr bgcolor="#9acd32"&gt;
                          &lt;th&gt;Subgroup&lt;/th&gt;
                          &lt;th&gt;DataName1&lt;/th&gt;
                          &lt;th&gt;DataName2&lt;/th&gt;
                          &lt;th&gt;DataName3&lt;/th&gt;
                          &lt;th&gt;DataName4&lt;/th&gt;
                      &lt;/tr&gt;
                      &lt;xsl:apply-templates/&gt;
                  &lt;/table&gt;
              &lt;/body&gt;
          &lt;/html&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="SubGroup"&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;xsl:value-of select="@Name"/&gt;&lt;/td&gt;
              &lt;xsl:apply-templates/&gt;
          &lt;/tr&gt;
      &lt;/xsl:template&gt;
      &lt;xsl:template match="Data"&gt;
          &lt;td&gt;&lt;xsl:apply-templates/&gt;&lt;/td&gt;
      &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>I get this ...</p>
  
  <pre><code>____________________________
  NameIWant1 | 1 | 2 | 3 | 4 |
             | 6 | 7 | 8 | 9 |
  </code></pre>
  
  <p>I would like to get..</p>
  
  <pre><code>____________________________
  NameIWant1 | 1 | 2 | 3 | 4 |
  </code></pre>