使用XSLT过滤XML

时间:2014-12-09 16:20:40

标签: xml xslt xpath transformation

我需要过滤转换中返回的数据。阅读我的示例代码,您将能够看到我在这里尝试做什么。我很感激帮助。感谢。

<xsl:variable select="Records/Record[@level = '12345']/Field[@g = 'A67890']" name="Var1"/>
            <xsl:variable select="Records/Record[@level = '12345']/Field[@g = 'B67890]" name="Var2"/>
            <xsl:variable select="Records/Record[@level = '12345']/Field[@g= 'C67890']" name="Var3"/>
            <xsl:variable select="Records/Record/Record[@level = 'ABC']/Field[@g = 'D123']" name="Var4"/>
            <xsl:variable select="Records/Record/Record[@level = 'ABC']/Field[@g = 'C123']" name="Var5"/>
            <xsl:if test="(contains($Var1= 'And') and ($Var2 = $Var4) and ($Var3 = $Var5) or contains($Var3= 'Or')">


    ----------**Code that is ran after if test**

    </xsl:if>

1 个答案:

答案 0 :(得分:0)

如果您正在寻找的是正确的if语法,那么:

<xsl:if test="(contains($Var1, 'And')
               and ($Var2 = $Var4)
               and ($Var3 = $Var5)
               or contains($Var3, 'Or')">


----------**Code that is ran after if test**

</xsl:if>