Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
XSLT选择应用过滤器_Xslt - Fatal编程技术网

XSLT选择应用过滤器

XSLT选择应用过滤器,xslt,Xslt,我有以下问题: 我想在choose中使用此选项: <xsl:variable name="Rows" select="/dsQueryResponse/Table/Rows/Row" /> 我试过: <xsl:variable name="Rows"> <xsl:choose> <xsl:when test="$paramId"> <xsl:copy-of select="/dsQuery

我有以下问题:

我想在choose中使用此选项:

<xsl:variable name="Rows" select="/dsQueryResponse/Table/Rows/Row" />

我试过:

<xsl:variable name="Rows">
    <xsl:choose>
        <xsl:when test="$paramId">
            <xsl:copy-of select="/dsQueryResponse/Rows/Row" />
        </xsl:when>
        <xsl:otherwise>
            <xsl:copy-of select="/dsQueryResponse/Rows/Row[@ID=$paramId]" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:variable>

但它不起作用,有人知道吗


只是为了澄清一下,基于paramId如果它是空的,那么我应该得到所有的行,但是如果paramId不是空的,我想应用filter ID=paramId,我怎么做呢?

假设您将paramId声明为

<xsl:param name="paramId" select="''" />

这完全取决于您如何声明和初始化所拥有的参数或变量,而您没有显示代码的这一部分

假设你有

<xsl:param name="paramId" select="/.."/>

那我就这么做了

<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[not($paramId) or @ID = $paramId]"/>


你能详细说明你的问题吗?我已经更新了帖子,解释更多:基本上基于参数,我会对行集合应用或不应用过滤器。你能显示你的输入XML吗?
<xsl:variable name="Rows" select="/dsQueryResponse/Rows/Row[not($paramId) or @ID = $paramId]"/>