[xsl] XSLT 2 - Sorting data with two elements named the same

Subject: [xsl] XSLT 2 - Sorting data with two elements named the same
From: Chris Hughes <chris_hughes22@xxxxxxxxxxx>
Date: Thu, 12 Jun 2008 09:24:17 +0000 (GMT)
I'm using XSLT 2, and Saxon 9.0.0.6.
 
I am recieveing the following error message
 
XTTE1020: A sequence of more than one item is not allowed as the @select
attribute of xsl:sort.
 
I understand why I have this message, my post is simply how can I make this
work, my data is structured like so
 
<Person name="Chris">
  <Rating type="Adjusted" value="100">
  <Rating type="Actual" value="99.6">
</Person>
<Person name="John">
  <Rating type="Adjusted" value="95">
  <Rating type="Actual" value="97.6">
</Person>
<Person name="Dave">
  <Rating type="Adjusted" value="90">
  <Rating type="Actual" value="81.6">
</Person>
....
 
I appreciate there is no logic to this data, its just an example as I can't
post my real data ;)
I want to sort the data by the Adjusted rating only, and then output a list of
adjusted ratings followed by the person name i.e.
 
100 Chris, 95 John, Dave 90 .....etc
 
So my XSL is currently trying the load the data into a variable which is when
I receive the error message
 
                <xsl:variable name="sortedratings">
                  <xsl:for-each select="Person[Rating/@type = 'Adjusted']">
                    <xsl:sort select="Rating/@value" data-type="number"
order="descending"/>
                    <xsl:copy-of select="."/>
                  </xsl:for-each>
                </xsl:variable>
 
I then go onto work with this variable.
 
So my question is how can I sort this data just by the one adjusted Rating
element, and still have access to the partent node.
 
Thanks.


      __________________________________________________________
Sent from Yahoo! Mail.
A Smarter Email
http://uk.docs.yahoo.com/nowyoucan.html

Current Thread