Xsl: How can I Group and sort based on sum?

前端 未结 1 1507
无人及你
无人及你 2021-01-21 21:01

I have the below xml

 
  
  

        
1条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-21 21:39

    Something like this (I have re-constructing your code, as it was missing quite a lot):

    This XSLT transformation:

    
    
     
    
     
    
        
            
                      
    
                    
                    
    
                    
                    

    when applied on the originally provided XML document:

    
        
        
        
        
        
        
    
    

    produces the wanted result):

    Sen        17    1  16
    Dong       41   37   4
    Mei        61   61   0
    
    

    Do note the following:

    1. The summation of the values of the @Pass or the @Fail attribute for the elements that belong only to the current group (the use of the key() function).

    2. The use of the instruction to sort by the required sums.

    3. The use of a global parameter named pSortBy, which contains the name of the attribute on the sums of which to sort.

    4. The use of the XSLT function current()

    0 讨论(0)
提交回复
热议问题