[xsl] how to sort a union using number()?

Subject: [xsl] how to sort a union using number()?
From: Andrew S Halper <ashalper@xxxxxxxx>
Date: Thu, 15 Mar 2007 16:43:43 -0700
Greetings,

I was wondering if someone might explain how to sort a union of nodes 
using the number() function.

I encountered a point where I needed to apply templates to a union of 
nodes, sorting them on a common element.

The naive approach was (XPaths radically simplified for brevity):

<xsl:apply-templates
     select="Classifier.feature/Attribute|$associations">
  <xsl:sort
       select="number(NumberString|$associations/NumberString)"/>
</xsl:apply-templates>

but this resulted in:

Error on line 228 of file:/e:/schema.xsl:
  XPTY0004: A sequence of more than one item is not allowed as the first 
argument of number()

I'm using Saxon 8.9J.

Thank you very much,
Andy Halper

Current Thread