相关疑难解决方法(0)

在<xsl:sort select =""/>中使用变量

您好我建立了一个通用模板来列出我的内容.但是Content可以在不同的@或node()上进行排序.所以想要传递xPath.

<xsl:variable name="sort" select="@sortBy"/>
<xsl:variable name="order" select="@order"/>

<xsl:for-each select="Content[@type=$contentType]">
  <xsl:sort select="$sort" order="{$order}" data-type="text"/>
  <xsl:sort select="@update" order="{$order}" data-type="text"/>
    <xsl:copy-of select="."/>
</xsl:for-each>
Run Code Online (Sandbox Code Playgroud)

使用变量以升序或降序进入order=""WORKS.

为什么不能这样做select=""呢?

我希望使这个超级动态的select变量可以是xPtah @publish或Title/node()或任何xPath.

没有错误 - 它只是忽略了排序.

xml xslt xpath

12
推荐指数
1
解决办法
1万
查看次数

标签 统计

xml ×1

xpath ×1

xslt ×1