有人可以帮我解决以下问题:
<xsl:variable name="filterByNameA" select="*/person[firstName=$fname] "/>
如果可能的话我想这样做
<xsl:variable name="filterByNameA" select="*/person[firstName=$fname] and */person[secondName=$fname]"/>
换句话说,我需要在一个变量中有两个条件,才能获取具有相同 firstName
和 secondName 的所有
。 person
元素
最佳答案
将两个测试放在同一个谓词中:
<xsl:variable name="filterByNameA" select="*/person[firstName=$fname and secondName=$fname]"/>
或者等效地,使用两个谓词:
<xsl:variable name="filterByNameA" select="*/person[firstName=$fname][secondName=$fname]"/>
当您有这样的连续谓词时,每个谓词都会过滤前一个谓词产生的列表,因此它们会有效地和
组合在一起
关于xslt 变量 xpath 表达式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20502524/