Xslt 检查属性是否等于值、不同于值或未定义

Xslt 检查属性是否等于值、不同于值或未定义,xslt,xslt-1.0,Xslt,Xslt 1.0,我有下面的xsl:choose标记,它基于某些条件 <MaturityDate> <xsl:choose> <xsl:when test="../../../../@name !='WQA'"> <xsl:value-of select="Apsml:unadjustedDate"/> </xsl:when> <xsl:otherwise> <xsl:value

我有下面的xsl:choose标记,它基于某些条件

<MaturityDate>
 <xsl:choose>
    <xsl:when test="../../../../@name !='WQA'">
        <xsl:value-of select="Apsml:unadjustedDate"/>
    </xsl:when>
    <xsl:otherwise>
        <xsl:value-of select="Apsml:adjustedTerminationDate"/>
    </xsl:otherwise>
 </xsl:choose>
</MaturityDate>

如上图所示,如果名称等于WQA,则执行某些操作;如果产品不是WQA,则执行某些操作。现在我想添加第三个条件,如果上述两个条件都不成立,那么它应该显示null

<xsl:value-of select="'null'" />


请建议如何添加第三个条件,即如果这两个条件都不成立,则最后应显示为null

属性
name
的值可以等于
'WQA'
或不同于
'WQA'
;(唯一)另一种选择是该属性不存在

因此,您可以使用:

<xsl:choose>
    <xsl:when test="../../../../@name ='WQA'">
        <xsl:value-of select="Apsml:adjustedTerminationDate" /> 
    </xsl:when>
    <xsl:when test="../../../../@name !='WQA'">
        <xsl:value-of select="Apsml:unadjustedDate" /> 
    </xsl:when>
    <xsl:otherwise>
        <!-- @name does not exist -->
        <xsl:value-of select="'null'" />
    </xsl:otherwise>
</xsl:choose>

如果要显式检查属性不存在时的情况,可以使用测试
not(../../../../../@name)