1
我想用嵌套的if语句来测试一些值,但它似乎不起作用。第一次当块工作正常,但当它碰到否则进入时,测试= $国家,它打破。文字“外部时间和国家是...”正常工作。问题是最后两段没有打印出来。我不确定这是否与嵌套when语句的方式有关,因为我是XSLT新手。如何嵌套when/otherwise语句?
国家是当我更改网站的区域设置为美国或GB。
<xsl:choose>
<xsl:when test="target = 'FX'"> <!-- Normal page -->
<xsl:choose>
<xsl:when test="$country = 'US'">
<p>Inside FX US. Country is <xsl:value-of select="$country" /></p>
</xsl:when>
<xsl:otherwise>
<p>Inside FX GB. Country is <xsl:value-of select="$country" /></p>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise> <!-- Graph page -->
<p>Outside when and country is <xsl:value-of select="$country" /></p>
<xsl:when test="$country = 'US'">
<p>Inside LPBM US. Country is <xsl:value-of select="$country" /></p>
</xsl:when>
<xsl:otherwise>
<p>Inside LPBM GB. Country is <xsl:value-of select="$country" /></p>
</xsl:otherwise>
</xsl:otherwise>
</xsl:choose>
请添加XML输入和期望的输出HTML。嵌套''很可能不是你最好的选择。 –
Tomalak