【发布时间】:2012-08-06 09:21:19
【问题描述】:
我对 xslt 很陌生
我有以下 xslt sn-p (为了清楚起见是伪的):
<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 块
真的有两个问题:
为什么它不能按原样工作?
我怎样才能实现我的目标?
【问题讨论】:
标签: xslt nested conditional