私はxsltにかなり慣れていません
次の xslt スニペットがあります (わかりやすくするために疑似的にしています)。
<xsl:for-each select="fields/field">
<xsl:if test="field=someThing">
<div>
<!--some content output-->
<!--here by doing-->
<!--some complex stuff-->
</div>
</xsl:if>
</xsl:for-each>
しかし、ループからのフィールドの値に基づいて、必要に応じて、最後の div の前に他のことをしたいと考えています。
だから(ピカピカの新しいxsl本で武装して)私は次のようなことができると思った:
<xsl:for-each select="fields/field">
<xsl:if test="field=someThing">
<div>
<!--some content output-->
<!--here by doing-->
<!--some complex stuff-->
<xsl:choose>
<xsl:when test="field=someThingSpecific">
<div>
<!--process some additional-->
<!--stuff here-->
</div>
<!--then close div-->
</div>
</xsl:when>
<xsl:otherwise>
<!--nothing to do here-->
<!--just close the div-->
</div>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
</xsl:for-each>
しかし、それは爆発します。
どうやら、終了 div が条件付き xsl:choose ブロックに移動したためです。
だから本当に2つの質問:
なぜそのままでは動作しないのですか?
どうすれば目的を達成できますか?