Find maximum value of all child elements and get its parent element in XSLT

后端 未结 3 1234
一生所求
一生所求 2021-01-06 05:51

Using the below XML, I need to figure out which person worked more hours in each site. For instance in the below XML, person 1 worked 8 hours in site 1 but person 2 worked o

3条回答
  •  隐瞒了意图╮
    2021-01-06 06:41

    This XSLT 1.0 transformation:

    
     
    
     
    
     
    
     
    
     
      
        
          
            
            
             
               
             
            
          
        
      
     
    
    

    when applied on the provided XML document:

    
        
            8
        
        
            2
        
        
            9
        
        
            6
        
        
            10
        
        
            2
        
    
    

    produces the wanted, correct result:

    
        
        
        
    
    

    Do note:

    1. The use of the Muenchian method for grouping to find all different Site values.

    2. The way maximum is found by sorting in descending order and getting the first result from the sorted node-list.

提交回复
热议问题