I would like for the vDonations to be in decending order I get this error when I try to run it
Unexpected element
xsl:sort
Code
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="ppathPersons" select="'file:///C:\Users\Randy\Documents\xml\projects\persons.xml'"/>
<xsl:param name="ppathDonations" select="'file:///C:\Users\Randy\Documents\XML\projects\money.xml'"/>
<xsl:variable name="vPersons" select="document($ppathPersons)"/>
<xsl:variable name="vDonations" select="document($ppathDonations)"/>
<xsl:template match="/">
<html>
<head>
<link href="money.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h2>The Lighthouse Donation List</h2>
<p><img src="logo.jpg"/></p>
<table>
<tr>
<th>Donor</th>
<th>Donation</th>
</tr>
<xsl:apply-templates select="$vPersons/*/person"/>
</table>
</body>
</html>
</xsl:template>
<xsl:template match="person">
<tr>
<td colspan="1">
<xsl:value-of select="concat(firstName, ' ', lastName)"/>
<xsl:value-of select="concat(' ',street,' ' , city,' ', state, ' ', zip, ' ', phone)"/>
</td>
<td colspan="1">
<xsl:value-of select="$vDonations/*/*[@pin = current()/@pid]/@amount"/>
<xsl:for-each select="$vDonations">
<xsl:sort select="$ppathDonations" data-type="number" order="descending" case- order="upper-first"/>
</xsl:for-each>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
If you want the donations made by the same person displayed within one
tdin decreasing order, use:In case you want to display all donations in decreasing order, modify your transformation to this one:
When this transformation is executed with the two XML files you provided in your first question, the wanted, correct result is produced: