Click to See Complete Forum and Search --> : Element xsl:sort not allowed here.


conputerguy99
10-13-2005, 06:06 PM
I tried to put and xsl:sort command in my xsl file. Does anyone understand why it says this?

<xsl:sort select="/owner">
<html>
<body>
<table border="1" cellpadding="2">
<tr>
<th>Owner:</th>
<th>Model:</th>
<th>Color:</th>
</tr>
<xsl:for-each select="catalog/car">
<tr>
<td><xsl:value-of select="owner" /></td>
<td><xsl:value-of select="model" /></td>
<td><xsl:value-of select="color" /></td>
</tr>
</xsl:for-each>
<xsl:for-each select="catalog/truck">
<tr>
<td><xsl:value-of select="owner" /></td>
<td><xsl:value-of select="model" /></td>
<td><xsl:value-of select="color" /></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:sort>

I have all the correct headers, but whenever I add xsl:sort it messes up.

teach_me
10-14-2005, 12:49 AM
hope xsl:sort will not have a separate close tag. it'll be closed at the place where it is opened.
example:


<?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>
</tr>
<xsl:for-each select="catalog/cd">
<xsl:sort select="artist"/>
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>



in the code u gave, u can keep the sort statement soon after the for-each opening tag.

conputerguy99
10-14-2005, 04:14 PM
Thanks!