title: xsl:for-each loop counter
body: <p>How do I save the iterations that have occurred in an xsl:for-each? (variables in XSL are immutable)</p>
  
  <p>My goal is to find the MAX number of children for any node at a particular level.</p>
  
  <p>For example, I might want to print that there are no more than 2 Response nodes for any Question in this survey:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1"?&gt;
  &lt;?xml-stylesheet type="text/xsl" href="testing.xsl"?&gt;
  &lt;Survey&gt;
    &lt;Question&gt;
      &lt;Response text="Website" /&gt;
      &lt;Response text="Print Ad" /&gt;
    &lt;/Question&gt;
    &lt;Question&gt;
      &lt;Response text="Yes" /&gt;
    &lt;/Question&gt;
  &lt;/Survey&gt;
  
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&gt;
  &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
  &lt;xsl:template match="/"&gt;
    &lt;html&gt;
    &lt;head&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;xsl:for-each select="Survey"&gt;
        The survey has &lt;xsl:value-of select="count(child::Question)"/&gt; questions.  
        &lt;br /&gt;
        &lt;xsl:variable name="counter"&gt;0&lt;/xsl:variable&gt;
        &lt;xsl:for-each select="Question"&gt;
          &lt;!-- TODO: increment the counter ??????? --&gt;
        &lt;/xsl:for-each&gt;
        No more than &lt;xsl:value-of select="$counter"/&gt; responses were returned for any question.
      &lt;/xsl:for-each&gt;
    &lt;/body&gt;
    &lt;/html&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>