Performing a “Group By” query in XPath XSL

后端 未结 2 973
无人及你
无人及你 2021-01-01 02:32

Given the following XML:


  11 
  

        
2条回答
  •  萌比男神i
    2021-01-01 02:45

    To do this in XSLT 1.0, you will have to use a technique called "muenchian grouping". First create a key of the nodes on which you wish to group

    
    

    Next, you iterate it through all the nodes, but only selecting the ones that happen to be first in the relevant group

    
    

    Next, you can iterate use the key to iterate over all nodes in the group

    
    
    

    Putting this all together gives

    
       
       
       
          
             
                
                
                   
                      
                   
                   
                      
                         
                            
                         
                         
                      
                   
                
             
          
       
    
    

    In your example, 'intfield' becomes 'numberfield' though. I have kept the name as 'intfield' in the above example.

    • fixed typo.

提交回复
热议问题