XSLT StyleSheet XML

File: Data.xml


  
    

S


    key 


    S


    T


    M


    X


    F


    

Steps for grouping in XSLT 2.0


    A


    B


    C


    D


  

File: Transform.xslt

     xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  
  
                group-adjacent="if (self::p[@class='item']) then 1 
                          else if (self::p[@class='note']) then 2 
                          else 3">
          
            
              

                    
                      

  •                     
                        
                      

  •                 
                  

            
            
              
                
              
                


                                              select="if (count(current-group()) gt 1)
                                then 'Notes' 
                                else 'Note'"/>
                


                    
                      
                        

  •                           
                              
                            

  •                       
                         
                
                
                  
                    
                  
                

              

            
      
      
        
          
          
        

      

    Output:

    S



         
    • key 
         

    •    
    • S


    Notes



       
  • T

  •    
  • M

  •    
  • X



    •    
    • F


    Steps for grouping in XSLT 2.0



         
    • A

    •    
    • B


    Note



       
  • C



    •    
    • D