I have a fairly large XSL document for a job that does a number of things. It is almost complete, but I missed the requirement that it be sorted, and I cannot get it to work. There is an SSCCE of what is happening.
<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/"> <html> <body> <xsl:apply-templates select="staff"> <xsl:sort select="member/last_name" /> </xsl:apply-templates> </body> </html> </xsl:template> <xsl:template match="member"> <xsl:value-of select="first_name" /> <xsl:value-of select="last_name" /> <br/> </xsl:template> </xsl:stylesheet>
The XML file is as follows:
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="sort.xsl"?> <staff> <member> <first_name>Joe</first_name> <last_name>Blogs</last_name> </member> <member> <first_name>John</first_name> <last_name>Smith</last_name> </member> <member> <first_name>Steven</first_name> <last_name>Adams</last_name> </member> </staff>
I expected employees to be listed by last name, but they are not sorted. Please keep in mind that I am very inexperienced in XSLT.
Christopher
source share