I want to sort these elements in ascending order but with the nulls last rather than first which seems to be what xslt does by default. I've managed to do this but wonder if there is a better way. Here's my example.
<b>
<c>2</c>
<c>1</c>
<c>3</c>
<c></c>
<c>15</c>
<c>11</c>
<c></c>
<c>43</c>
<c>4</c>
</b>
<xsl:template match="/">
<xsl:for-each select="b/c">
<xsl:sort select="node() = false()"/>
<xsl:sort select="." data-type="number"/>
Row<xsl:value-of select="position()"/>:<xsl:value-of select="."/>
</xsl:for-each>
</xsl:template>
Which gives the required output of:
Row1:1
Row2:2
Row3:3
Row4:4
Row5:11
Row6:15
Row7:43
Row8:
Row9:
I'm currently using <xsl:sort select="node() = false()"/>
to test for it being null then using a sort to order the null elements last (null will be 1 and not null will be 0 so it orders them correctly).
Can anyone suggest anything better than this?