如何退出「的for-each」在XSL循環,如果條件滿足? 例如假設我想的XSL顯示已公寓的地址(2間臥室和租金< = 1000),在下面的XML,下面的XSL代碼:XSLT:如何退出「的for-each」循環,如果條件滿足
<xsl:for-each select="//apartment/apartment_details">
<xsl:if test="bedrooms=$bedrooms and rent <= $budget ">
<!--display apartment address-->
</xsl:if>
</xsl:for-each>
將兩次返回相同的公寓地址。我只想即使有多個用於滿足條件的公寓顯示一次的公寓地址。
XML結構:
<apartments>
<apartment>
<address>
<street>....</street>
<city>....</city>
</address>
<apartment_details>
<bedrooms>2</bedrooms>
<bathrooms>2</bathrooms>
<rent>1000</rent>
</apartment_details>
<apartment_details>
<bedrooms>2</bedrooms>
<bathrooms>1</bathrooms>
<rent>900</rent>
</apartment_details>
...
</apartment>
...
</apartments>
謝謝。
「即使有多個_____爲滿足條件的公寓」 - 你似乎缺少一個字。 – LarsH
重複的http://stackoverflow.com/questions/470045/how-to-break-a-for-each-loop-in-xslt/8507243#8507243 – 2012-05-01 10:18:32