Sorting by using xsl:sort in a xsl:for-each

admin

Administrator
Staff member
I have a problem when trying to sort a xml-document using the xsl:sort elementin a xsl:for-each statement. What am i doing wrong?I got the messages:"Keyword xsl:sort may not be used here."in the browserXML-document:=====================================================================<?xml version='1.0' encoding='ISO-8859-1'?><?xml:stylesheet type='text/xsl' href='http://forums.devx.com/archive/index.php/TestSorting2.xsl'?><customers><customer><name>carina</name><adress>stockholm</adress><phone>1232</phone><nr>1</nr></customer><customer><name>kalle</name><adress>stockholm</adress><phone>1232</phone><nr>5</nr></customer><customer><name>pelle</name><adress>stockholm</adress><phone>1232</phone><nr>2</nr></customer><customer><name>olle</name><adress>stockholm</adress><phone>1232</phone><nr>3</nr></customer></customers>=====================================================================XSL-document:=====================================================================<?xml version="1.0" ?><xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><xsl:template match="/"><HTML><BODY><TABLE><xsl:for-each select="/customers/customer"><xsl:sort select="nr" order="ascending" data-type="number"/><TR><xsl:apply-templates select="name" /><xsl:apply-templates select="adress" /><xsl:apply-templates select="phone" /></TR></xsl:for-each></TABLE></BODY></HTML></xsl:template><xsl:template match="name"><TD STYLE="font-size:14pt font-family:serif"><xsl:apply-templates /></TD></xsl:template><xsl:template match="adress"><TD> <xsl:apply-templates /> </TD></xsl:template><xsl:template match="phone"><TD> <xsl:apply-templates /> </TD></xsl:template><xsl:template match="text()"><xsl:value-of /></xsl:template></xsl:stylesheet>=====================================================================
 
Back
Top