0

I have XSLT where

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

I need to output, where first sort value is defined text value @ows_plstx='specific value' and then xslt sort other @ows_plstx values in ascending order.

Example

First defined @ows_plstx specific value

Other @ows_plstx values

...

...

How can I achieved that? Sorry, I am not very familiar with XSLT.

4

1 回答 1

0

You can use the fact that boolean true converts to the number 1 and boolean false converts to the number 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') is 1 for the "specific value" and 0 for all other values, so sorting in descending order by those numeric values should put the "specific value" first. Technically the number() call in that select isn't necessary but I think it makes it a bit clearer.

于 2013-03-27T16:16:34.353 回答