3. Sorting

Let's take a look at XSLT produced by the following 'xml sel' command:

# Query XML document and produce sorted text table
xml sel -T -t -m /xml/table/rec -s D:N:- "@id" \
   -v "concat(@id,'|',numField,'|',stringField)" -n xml/table.xml
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="no" method="text"/>
<xsl:param name="inputFile">-</xsl:param>
<xsl:template match="/">
  <xsl:call-template name="t1"/>
</xsl:template>
<xsl:template name="t1">
  <xsl:for-each select="/xml/table/rec">
    <xsl:sort order="descending" data-type="number" 
      case-order="upper-first" select="@id"/>
    <xsl:value-of select="concat(@id,'|',numField,'|',stringField)"/>
    <xsl:value-of select="'&#10;'"/>
  </xsl:for-each>
</xsl:template>
</xsl:stylesheet>

-s option of 'xml sel' command controls 'order', 'data-type', and 'case-order' attributes of <xsl:sort/> element .