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



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

Answer / 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

More XML XSLT RSS Interview Questions

Can we use xml as database?

1 Answers  


What are xml entities used for?

1 Answers  


Tell me can we use graphics in xml?

1 Answers  


What is xml tag library?

1 Answers  


What is XML Namespace?

1 Answers  


Give a few examples of types of applications that can benefit from using XML.

1 Answers  


Can we debug xml file?

1 Answers  


what is difference between mail sendig in .net 1.1 and .net 2.0

1 Answers  


How do I run an xml file?

1 Answers  


What are the elements of xml?

1 Answers  


How to use filtering function in XSLT?

1 Answers  


What are the various advantages of xsl?

1 Answers  


Categories