What Data Types Does XSLT Sort Support?

The data-type attribute in the XSLT <xsl:sort> element controls how items are compared during node ordering, distinguishing between alphabetic collation and numerical evaluation. The standard W3C XSLT 1.0 and 2.0/3.0 specifications natively define two core enumerated values—text and number—while also allowing QName extension types or explicit XML Schema data types depending on the processor version.

Standard Data Types in XSLT 1.0

In XSLT 1.0, the data-type attribute accepts two primary standard values:

XSLT 1.0 also allows a prefixed QName (Qualified Name) to support implementation-defined, vendor-specific sorting algorithms, though portable stylesheets generally stick to text and number.

Enhancements in XSLT 2.0 and 3.0

XSLT 2.0 and XSLT 3.0 expand on sorting capabilities through integration with W3C XML Schema data types:

Basic Syntax Example

Sorting nodes numerically in an XSLT template:

<xsl:for-each select="product">
  <xsl:sort select="price" data-type="number" order="ascending" />
  <p><xsl:value-of select="name"/>: $<xsl:value-of select="price"/></p>
</xsl:for-each>