Function that can be use to omit duplicate value on a string

后端 未结 4 2008
无人共我
无人共我 2020-12-22 12:27

I would like to ask if there is a function that can be use to to remove a duplicate value inside a string separated by | simplest possible way. I have below example of the s

4条回答
  •  难免孤独
    2020-12-22 12:46

    To do this in pure XSLT 1.0, with no extension functions, you will need to use a recursive named template:

    
        
                  
        
            
                
                           
                
                
                    
                
                
                
                    
                
            
            
                
            
           
    
    

    Full demo: http://xsltransform.net/ncdD7mM


    Added:

    The above method outputs the last occurrence of each value in the list, because that's the simplest way to remove the duplicates.

    The side effect of this is that the original order of the values is not preserved. Or - more correctly - it is the reverse order that is being preserved.

    I would not think preserving the original forward order is of any importance here. But in case you do need it, it could be done this way (which I believe is much easier to follow than the suggested alternative):

    
        
            
         
        
            
                 
                
                
                    
                    
                        
                        
                        
                            
                        
                    
                
            
            
                
            
           
    
    

提交回复
热议问题