title: XSLT: How to exit a "for-each" loop if a condition is satisfied
body: <p>How do I exit a "for-each" loop in XSL if a condition is satisfied?
  e.g. Suppose I want the XSL to display the address of apartments which have (2 bedrooms and rent &lt;= 1000), in the following XML, the following XSL code:</p>
  
  <pre><code>&lt;xsl:for-each select="//apartment/apartment_details"&gt;
    &lt;xsl:if test="bedrooms=$bedrooms and rent &amp;lt;= $budget "&gt; 
      &lt;!--display apartment address--&gt; 
    &lt;/xsl:if&gt;
  &lt;/xsl:for-each&gt;
  </code></pre>
  
  <p>would return the same apartment address twice. I want to display the apartment address only once even if there are multiple  for the apartment that satisfy the condition.</p>
  
  <p>XML structure:</p>
  
  <pre><code>&lt;apartments&gt;
    &lt;apartment&gt;
      &lt;address&gt;
          &lt;street&gt;....&lt;/street&gt;
          &lt;city&gt;....&lt;/city&gt;
      &lt;/address&gt;
      &lt;apartment_details&gt;
          &lt;bedrooms&gt;2&lt;/bedrooms&gt;
          &lt;bathrooms&gt;2&lt;/bathrooms&gt;
          &lt;rent&gt;1000&lt;/rent&gt;
      &lt;/apartment_details&gt;
      &lt;apartment_details&gt;
          &lt;bedrooms&gt;2&lt;/bedrooms&gt;
          &lt;bathrooms&gt;1&lt;/bathrooms&gt;
          &lt;rent&gt;900&lt;/rent&gt;
      &lt;/apartment_details&gt;
      ...
    &lt;/apartment&gt;
    ...
  &lt;/apartments&gt;
  </code></pre>
  
  <p>Thank you.</p>