adspace


Can we do sorting in XSL ? how do you deal sorting columns
dynamically in XML.

Answer Posted / Najir Husen

Yes, we can sort data in XSL using the xsl:sort element. The xsl:sort element sorts nodes of a specific template based on their attribute or content. To handle dynamic sorting columns, you can add multiple xsl:sort elements with different attributes 'name' (for column name) and 'order' (for ascending or descending order) within the same xsl:template. For example:nn<xsl:template match="/">n <table border="1">n <xsl:for-each select="./*[1]">n <xsl:sort name={local-name()}n xsl:if test="./@sort" select=".@sort/text()" order="{./@sort/@order}"/>n <tr><th><xsl:value-of select=local-name()/></th>n <xsl:apply-templates select="./"/>n </tr>n </xsl:for-each>n </table>n</xsl:template>

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Do you feel that you have chosen the right technology xslt? : xslt

903


What are the ways to add styles to html?

997


Do you feel that you are a good xslt programmer? : xslt

869


Are you ready to relocate? : xslt

918