Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.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
Xml 在XSLT中使用IF函数确定字段是否为空,如果为空,则添加一个文本常量_Xml_Xslt - Fatal编程技术网

Xml 在XSLT中使用IF函数确定字段是否为空,如果为空,则添加一个文本常量

Xml 在XSLT中使用IF函数确定字段是否为空,如果为空,则添加一个文本常量,xml,xslt,Xml,Xslt,目前,我正在尝试使用XSLT创建一个IF样式语句。我希望语句的内容如下:如果此字段为空或包含单词“EMPTY”,则输出单词“NotDetermined” 这是我的XSLT: <FirstName> <--I believe the IF/Test statement should start around here--> <xsl:value-of select="FirstName"/> </FirstName> 试试这个 <xsl:v

目前,我正在尝试使用XSLT创建一个IF样式语句。我希望语句的内容如下:如果此字段为空或包含单词“EMPTY”,则输出单词“NotDetermined”

这是我的XSLT:

<FirstName>
<--I believe the IF/Test statement should start around here-->
<xsl:value-of select="FirstName"/>
</FirstName>

试试这个

<xsl:value-of select="if(normalize-space(FirstName) = '' or normalize-space(FirstName) = 'EMPTY') then 'NotDetermined' else FirstName"/>

还是这个

        <xsl:choose>
            <xsl:when test="normalize-space(FirstName) = '' or normalize-space(FirstName) = 'EMPTY'"><xsl:text>NotDetermined</xsl:text></xsl:when>
            <xsl:otherwise>
                <xsl:value-of select="FirstName"/>
            </xsl:otherwise>
        </xsl:choose>

不确定

您可以将条件(在这两种情况下)缩写为
test=“normalizespace(FirstName)=(''‘EMPTY')”
请注意:这是XSLT 2.0