How sort elements and store them in a variable, XSLT

后端 未结 3 1451
不思量自难忘°
不思量自难忘° 2021-01-20 19:59

I was wondering whether it\'s possible to sort some elements first and store them (already sorted) in a variable. I would need to refer to them thought XSLT that\'s why I\'d

3条回答
  •  [愿得一人]
    2021-01-20 20:35

    1. Using XSLT version 2.0 you could use perform-sort and tell that your variable is of type of a sequence of MultiDeposits using the as keyword (as="element(MultiDeposits)+")
    2. Since your data is already as yyyy-mm-dd you can avoid to use the subtring to get each part of the date and use the sort directly on the field

    with this sample xml:

    
    
      1
      2
      3
      4
      5
    
    

    and using the XSLT version 2.0 sheet:

    
    
    
     
     
      
    
      
       
        
       
      
    
      first date:,
      last date:
    
      
     
     
    
    
    

    the ouput will be:

    first date:1998-01-01, last date:2010-08-09
    

提交回复
热议问题