XSLT sort

XSLT <xsl:sort> Element

To sort the output, we can use the <xsl:sort> element.

Where to use the Sort Information:

In the XSL file, we can simply add an <xsl:sort> element inside the <xsl:for-each> element, to sort the output. To specify what XML element to sort on, the select attribute is used.

Example:

Books.xml:




  
    ABC
    Author Name
    2020
    100.00
  

  
    XQuery Book
    Author 1
    Author 2
    2018
    300.00
  

  
    Sociology 1
    Author Name
 2010
    250.00
  

  
    Current Affairs
    Author Name
    2019
    500.00
  

  
    Science Book
    Author 1
    Author 2
    Author 3
    2017
    150.00
  


XSLT Code:





  
  
    

List of Books

Title Price

Output:

Please follow and like us:
Content Protection by DMCA.com