XSLT 1.0 sort elements

afreddyclueger

New Member
I have the following XML document:\[code\]<?xml version="1.0" encoding="UTF-8"?><objects> <object>Clutch</object> <object>Gearbox</object> <object>Cylinder head</object> <object>Starter</object> <object>Airbox</object> <object>Inlet manifold</object></objects>\[/code\]And the following XSLT document:\[code\]<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" indent="yes"/> <xsl:template match="objects"> <parts> <xsl:apply-templates> <xsl:sort select="object"/> </xsl:apply-templates> </parts> </xsl:template> <xsl:template match="object"> <part> <xsl:apply-templates/> </part> </xsl:template></xsl:stylesheet>\[/code\]When applied I am getting the following output as expected, but it is not being sorted:\[code\]<?xml version="1.0" encoding="UTF-8"?><parts> <part>Clutch</part> <part>Gearbox</part> <part>Cylinder head</part> <part>Starter</part> <part>Airbox</part> <part>Inlet manifold</part></parts>\[/code\]Why is the \[code\]<xsl:sort select="object"/>\[/code\] not being applied ?
 
Back
Top