title: How to do a "while"-like loop in XSLT?
body: <p>I'm a novice in XSLT and I'm struggling a lot with this issue: I need to do a while-like loop in XSLT. I don't think the for-each will be enough to solve this problem.</p>
  
  <p>I have a variable that is the result of a SELECT statement. It can return 0 or an integer. If the value is 0, it needs to do the SELECT again sending another parameter to see if the value is different.</p>
  
  <p>I can only think in using a while-like loop, but maybe it has another way of achieving this? Like using a template and calling itself in the end? Is it possible?</p>
  
  <p>Something like that:</p>
  
  <pre><code>&lt;!-- initiate TEMPLATE --&gt;
  &lt;!-- WHILE $VALUE = 0 --&gt;
  &lt;xsl:variable name="sql.query"&gt;
      &lt;sql:param name="SQL_QUERY"&gt;SELECT $value FROM date_table WHERE date='$date'&lt;/mx:param&gt;
  &lt;/xsl:variable&gt;
  
  &lt;xsl:variable name="VALUE"&gt;
      &lt;xsl:value-of select="sql:exec-formula('generic.sql', exsl:node-set($sql.query)//sql:param)" /&gt; &lt;!-- this will bring the result of the SELECT in the variable --&gt;
  &lt;/xsl:variable&gt;
  
  &lt;xsl:variable name="date"&gt;
      &lt;xsl:value-of select="$date-1" /&gt; &lt;!-- something like that, it doesn't matter --&gt;
  &lt;/xsl:variable&gt;
  
  &lt;xsl:if test="$VALUE ='0'"&gt;
      &lt;!-- call template again --&gt;
  &lt;/xsl:if&gt;
  &lt;!-- end of template --&gt;
  </code></pre>