title: XSLT: Match first descendant element
body: <p>I'm trying to match the first <code>bar</code> element that occurs as a descendant of a <code>foo</code> element in an xsl match pattern and struggling. Initial attempt:</p>
  
  <pre><code>&lt;xsl:template match="//foo//bar[1]"&gt;
  ...
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>fails because there are several <code>bar</code> elements that match. So:</p>
  
  <pre><code>&lt;xsl:template match="(//foo//bar)[1]"&gt;
  ...
  &lt;/xsl:template&gt;
  </code></pre>
  
  <p>but that fails to compile.</p>