我是XSLT世界的新手。我只是想知道如何将我的选择结果保存到一个数组中并对该数组进行排序,然后选择我想要的数组和显示索引。在谷歌上搜索一下这个问题后,我可以在字段上使用sort。但我不想在内部使用XML,因为它会很长很复杂,而我宁愿存储结果然后再玩。
<?xml version="1.0" encoding="UTF-8"?>
<catalog>
<cd>
<title>Empire Burlesque</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
<date>2023-01-01</date>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
<date>2022-01-01</date>
</cd>
<cd>
<title>Greatest Hits</title>
<artist>Dolly Parton</artist>
<country>USA</country>
<company>RCA</company>
<price>9.90</price>
<year>1982</year>
<date>2021-01-01</date>
</cd>
</catalog>
XSLT:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th>Title</th>
<th>Artist</th>
<th>Date</th>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:sort select="date"/>
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
<td><xsl:value-of select="date"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
那么如何在一个地方收集所有日期然后对它们进行排序。感谢