XSLT xsl:apply-templates Element

We can apply a template rule to the current element or to the current element’s child nodes, using the <xsl:apply-templates> element.

The <xsl:apply-templates> Element:

A template is applied by the <xsl:apply-templates> element to the current element or to the current element’s child nodes. To process only the child elements that match a particular value, a “select” attribute can be added to the <xsl:apply-templates> element. The order in which the child nodes are to be processed can also be specified using the “select” attribute.

Example:

Books.xml:




  
    ABC
    Author Name
    2020
    100.00
  

  
    XQuery Book
    Author 1
    Author 2
 2005
    300.00
  

  
    Sociology 1
    Author Name
 2010
    250.00
  

  
    Current Affairs
    Author Name
 2004
    500.00
  

  
    Science Book
    Author 1
    Author 2
    Author 3
 2011
    150.00
  


XSLT Code:





  
  
  

List of Books

Title:
Price:

Output: