XSLT排序特定值

时间:2013-03-27 15:59:21

标签: sharepoint sorting xslt

我有XSLT在哪里

<xsl:for-each select="$Rows">
<xsl:sort select="@ows_plstx" order="ascending" />

我需要输出,其中第一个排序值定义为文本值@ ows_plstx ='特定值',然后xslt按升序排序其他@ows_plstx值。

实施例

首先定义@ows_plstx特定值

其他@ows_plstx值

...

...

我怎样才能实现这一目标?对不起,我对XSLT不太熟悉。

1 个答案:

答案 0 :(得分:0)

你可以使用boolean true转换为数字1的事实,boolean false转换为数字0

<xsl:for-each select="$Rows">
  <xsl:sort select="number(@ows_plstx = 'specific value')"
            order="descending" data-type="number" />
  <xsl:sort select="@ows_plstx" order="ascending" />

number(@ows_plstx = 'specific value')对于“特定值”为1,对于所有其他值为0,因此按这些数值按降序排序应首先放置“特定值”。从技术上讲,该选择中的number()调用不是必需的,但我认为它使它更清晰。