RE: [xsl] xsl:sort with nulls at end

Subject: RE: [xsl] xsl:sort with nulls at end
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Mon, 3 Nov 2008 18:19:03 -0000
> The issue I have is that if the row is missing that tag, the 
> sort puts that record first. Ie. Nulls come first. I need the 
> nulls to come last.
> Is there a way to get around this and force the nulls to be last?

Add further sort keys:

      <xsl:for-each select="*">
          <xsl:sort select="empty(X)"/>
          <xsl:sort select="X" order="ascending" data-type="text"/>
          <xsl:sort select="empty(Y)"/>
          <xsl:sort select="Y" order="descending" data-type="text"/>
          <xsl:sort select="empty(Z)"/>
          <xsl:sort select="Z" order="ascending" data-type="number"/>

Note that boolean false() sorts before true().

Michael Kay
http://www.saxonica.com/

Current Thread