Formatting scientific number representation in xsl

前端 未结 5 787
遇见更好的自我
遇见更好的自我 2020-12-03 19:45

I have the following value in my XML -1.8959581529998104E-4. I want to format this to the exact number it should be using XSL to give me -0.000189595815299981.

fo

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-03 20:36

    XSLT 1.0 does not have support for scientific notation.

    This: number('-1.8959581529998104E-4') Result: NaN

    This: number('-0.000189595815299981') Result: -0.000189595815299981

    XSLT 2.0 has support for scientific notation

    This: number('-1.8959581529998104E-4') Result: -0.000189595815299981

    EDIT: A very simple XSLT 1.0 workaround:

    
        
            
            
            
            
                
                    
                
                
                    
                
            
        
    
    

    With this input:

    -1.8959581529998104E-4
    

    Output:

    -0.00018959581529998104
    

提交回复
热议问题