如何在 XSLT 选择中执行“and”语句?

Ste*_*hen 5 xslt conditional-statements

使用运算符的复合 select 语句的示例是什么AND,类似于if条件 1 = true 且条件 2 = true 的语句?

Sco*_*ers 3

这是如何使用复合选择语句的示例......

<?xml version="1.0" encoding="ISO-8859-1"?>
<A>
    <B>
        <C>1</C>
        <D>2</D>
    </B>
    <B>
        <C>1</C>
        <D>3</D>
     </B>
    <E>test</E>
</A>
Run Code Online (Sandbox Code Playgroud)

并且您当前的模板匹配是“E”,然后尝试以下代码仅选择 B,其中 C = 1 且 D = 3:对于 C 和 D,读取条件 1 = true 且条件 2 = true

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml" version="1.0" indent="yes"/>
    <xsl:template match="E">
        <xsl:value-of select="../B[C = 1][D = 3]"></xsl:value-of>
    </xsl:template>
    <xsl:template match="C"/>
    <xsl:template match="D"/>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

祝你好运