首页 > 解决方案 > XSLT xsl:选择探针

问题描述

我的 xml 行之一如下所示:

<cf_task_subscription amount="1200.0" code="GBP">£1,200.00</cf_task_subscription>

我想设置一个 xls:choose 规则,如下所示,但我不能这样做,因为 XML 添加了 £ 符号:

<xsl:variable name="value" select="/hash/cf_task_subscription"/>
<xsl:choose>
    <xsl:when test="$value > 1200.0">John Doe</xsl:when>
    <xsl:when test="$value = 1200.0">Jane Doe</xsl:when>
    <xsl:otherwise>Unassigned</xsl:otherwise>
</xsl:choose>

所以我的问题是,有没有办法告诉 xsl 只考虑 cf_task_subscription 标记的 amount="1200.00" 部分?

谢谢,

标签: xsltxslt-1.0

解决方案


由于信息已在属性中以结构化形式精心提供,与文本节点中的“显示形式”分开,那么利用它:

<xsl:when test="$value/@amount > 1200.0">John Doe</xsl:when>

推荐阅读