I have the following xml file:
<WindowProperties>
<skin>LP Connect</skin>
<showToOperator>false</showToOperator>
<showToVisitor>false</showToVisitor>
<ChatWindow>
<field>
<key>direction</key>
<val>ltr</val>
</field>
<field>
<key>enableCustomizedHeaderImageUrl</key>
<val>false</val>
</field>
<field>
<key>brandType</key>
<val>noImage</val>
</field>
<field>
<key>brandHeight</key>
<val>158</val>
</field>
</ChatWindow>
I want to sort field in chat window using key element so the xml will look like:
<WindowProperties>
<skin>LP Connect</skin>
<showToOperator>false</showToOperator>
<showToVisitor>false</showToVisitor>
<ChatWindow>
<field>
<key>brandHeight</key>
<val>158</val>
</field>
<field>
<key>brandType</key>
<val>noImage</val>
</field>
<field>
<key>direction</key>
<val>ltr</val>
</field>
<field>
<key>enableCustomizedHeaderImageUrl</key>
<val>false</val>
</field>
</ChatWindow>
</WindowProperties>
I tried the following xsl:
<ChatWindow>
<xsl:template match="ChatWindow">
<xsl:for-each select="field">
<xsl:sort select="key"/>
<key><xsl:value-of select="key"/></key>
<value><xsl:value-of select="val"/></value>
</xsl:for-each>
</xsl:template>
</ChatWindow>
but this didn't work. Any help appreciated.