Subject:sorting elements in option Author:suresh chinta Date:22 Jan 2009 12:14 AM
I am trying to sort options in a drop down list. Following is my code, and I am not able to figure out why the options label elements are not getting sorted :
<!--Created a select element with attributes id and name-->
<xsl:element name="select">
<xsl:attribute name="id">
<xsl:value-of select="value/item[@name='dmfield_label']/value"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:value-of select="item[@name='Scrolling_Menu_Items']/value/item[@name='smfield_label']/value"/>
</xsl:attribute>
<!--Xsl:for-each to list all the options in dropdown-->
<xsl:for-each select="value/item[@name='dropdown']/value">
<xsl:sort select="value/item[@name='dropdown_label']/value" data-type="text" />
<!--Option element with attributes-->
<option>
<xsl:attribute name="value">
<xsl:value-of select="item[@name='dropdown_value']/value" />
</xsl:attribute>
<xsl:value-of select="item[@name='dropdown_label']/value" />
</option>
</xsl:for-each>
</xsl:element>