XSLT Custom Sort

后端 未结 4 1929
故里飘歌
故里飘歌 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:34

    Have you seen xsl:sort element, you can create two or more sorting criteria by combining xsl:apply-templates and xsl:sort

    Indeeed, here is a sample where some countries comes first, in a predefined order, then all the others. Note that these are elements, not attributes as above.

    
    
    
    

    Sample result:

    Country

    Scotland   
    Scotland 
    Scotland 
    India 
    Afghanistan 
    Afghanistan 
    Afghanistan 
    Afghanistan 
    Afghanistan 
    Afghanistan 
    Albania 
    Albania 
    Albania 
    Algeria
    

提交回复
热议问题