Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
If statement 在XSLT中为每个_If Statement_Xslt - Fatal编程技术网

If statement 在XSLT中为每个

If statement 在XSLT中为每个,if-statement,xslt,If Statement,Xslt,我有一个xslt文档。我想在这个文档中使用if语句。我的代码是: <xsl:for-each select="cbc:ProfileID"> <xsl:apply-templates/> <xsl:if test="cbc:ProfileID='code1'"> <xsl:text>A</xsl:text> </xsl:if> <xsl:if test="cbc:Pr

我有一个xslt文档。我想在这个文档中使用if语句。我的代码是:

<xsl:for-each select="cbc:ProfileID"> 
    <xsl:apply-templates/>

    <xsl:if test="cbc:ProfileID='code1'">
        <xsl:text>A</xsl:text>
    </xsl:if>
    <xsl:if test="cbc:ProfileID='code2'">
        <xsl:text>B</xsl:text>
    </xsl:if>

</xsl:for-each>

A.
B
如果返回值是code1,那么写A,如果返回值是code2,那么写B


如何做到这一点?

据我所知,您已经处于相同的上下文中,每个
都是
,因此您需要在如下情况下使用

<xsl:if test="normalize-space(.)='code1'">



这是否回答了您的问题?您应该发布示例xml和完整的代码,这样我们才能理解并能够正确回答。成功了。非常感谢:)如果有助于你实现你的愿望,请通过接受答案来结束问题。干杯
<xsl:if test=".='code1'">