使用变量的过滤器不支持XPATH表达式

时间:2014-04-20 13:24:41

标签: xpath

我的一个项目中有这个XSLT代码

<xsl:template match="strategic-objectives/list/item" mode="table-of-contents">    
  <div class="toc">
    <h3 class="report">Strategic objective: <a href="#sf_{flex_value}"><xsl:value-of select="title"/></a></h3>

    <xsl:variable name="flex_value" select="flex_value"/>
    <xsl:apply-templates select="//root/data/operational-outcomes/list/item[sf = $flex_value]" mode="table-of-contents"/>
  </div>
</xsl:template> 

我尝试了多少,<operational-outcomes>的数据与sf = flex_value不匹配,但sf = '020000'匹配。

我已检查<flex_value> <strategic-objectives>项是否适用于020000项目。它实际上也有<data xsql-timing="3131"> <time>20 of April, 2014 (14:22) </time> <strategic-objectives> <list type="strategic_objective" xsql-timing="81"> <item num="1"> <context>PB08V6 </context> <flex_value_set_name>ILO_AFF_SF </flex_value_set_name> <attribute5>10 </attribute5> <flex_value>010000 </flex_value> <hierarchy_level>1 </hierarchy_level> <title>Policy Making </title> </item> <item num="4"> <context>PB08V6 </context> <flex_value_set_name>ILO_AFF_SF </flex_value_set_name> <attribute5>10 </attribute5> <flex_value>200000 </flex_value> <hierarchy_level>1 </hierarchy_level> <title>Employment </title> <description> </description> <text> </text> </item> </list> </strategic-objectives> <operational-outcomes> <list type="outcome" xsql-timing="477"> <item num="9"> <context>PB08V6 </context> <flex_value_set_name>ILO_AFF_SF </flex_value_set_name> <flex_value>220025 </flex_value> <parent_flex_value>220000 </parent_flex_value> <hierarchy_level>3 </hierarchy_level> <status>10 </status> <attribute5>40 </attribute5> <title>REVISED - Policies for growth, employment and poverty reduction </title> <description></description> <text> </text> <sf>200000 </sf> </item> <item num="10"> <context>PB08V6 </context> <flex_value_set_name>ILO_AFF_SF </flex_value_set_name> <flex_value>740050 </flex_value> <parent_flex_value>740000 </parent_flex_value> <hierarchy_level>3 </hierarchy_level> <status>10 </status> <attribute5>40 </attribute5> <title>DELETED - Internal Administration and Security </title> <sf>700000 </sf> </item> </list> </operational-outcomes> </data> 作为其中一个值。

数据

{{1}}

1 个答案:

答案 0 :(得分:0)

查看XML源代码,存在空白问题:

<flex_value>200000    </flex_value> 

每个字符都很重要,200000␣␣␣␣200000不同。

normalize-whitespace()剥离前导和尾随空格,并将字符串中的多个后续空格字符折叠为一个。例如:

<xsl:variable name="flex_value" select="normalize-space(flex_value)"/>

␣␣foo␣␣␣bar␣␣变为foo␣bar