Summing numbers with comma as decimal separator in XSLT?

前端 未结 3 1692
时光取名叫无心
时光取名叫无心 2020-12-04 00:41

I have an XML file where the number are comma-separated


  
  
  
         


        
3条回答
  •  一生所求
    2020-12-04 01:39

    I am guessing, that the value specified in a "val" attribute is a number that has comma instead of a decimal point.

    Several solutions are possible:

    I. XSLT 1.0

    This transformation:

    
      
      
        
          
            
              
            
          
    
          
        
    
    

    when applied on the originally-provided XML document:

    
        
        
        
    
    

    produces the wanted result:

    13.68
    

    II. XSLT 2.0

    This transformation:

    
     
    
     
      
     
    
    

    when applied on the same XML document, produces the same correct result:

    13.68

    III. FXSL 2.x

    This transformation:

    
       
    
     
    
     
      
     
    
     
       
    
       
     
    
     
       
     
    
     
       
    
       
     
    
    

    when applied on the same XML document produces the same correct result:

    13.68

    The last solution is more flexible and can be used successfully when a more complex transformation of the values is needed before summing.

提交回复
热议问题