XSLT Custom Sort

后端 未结 4 1897
故里飘歌
故里飘歌 2021-01-14 11:15

Is it possible in XSLT to sort in alphabetical order, with 5 items as \"preferred\".

i.e. given




        
4条回答
  •  清酒与你
    2021-01-14 11:41

    In your XSLT, are you able to make use of extension functions?

    If so, one method is to modify the existing list of nodes in-line, to create a new node set but with an extra 'sortname' attribute on each node. You can then iterate through this new node set, sorting using the new 'sortname' attribute:

    
    
        
        
            
            
                
                    
                    
                        
                            1
                            2
                        
                        
                    
                
            
            
            
            
                
    
                
                    
                
            
            
        
    
    
    

    In the example above, I prefix a '1' onto any national team, and a '2' on any domestic team, and then sort on this new attribute.

    See information on Node Sets to see what XSLT processers support which extensions.

提交回复
热议问题