2012-03-06 2 views

답변

8

당신이 할 수있는 format-number() 함수를 사용하여 숫자를 주어진 형식의 문자열로 변환하십시오. "# .00 #########"형식 문자열을 사용하면 소수점 두 자리 이상이 표시됩니다.

당신은 할 수는 54.2,54.23,54.234,54.234567 같은 값을 포함하는 XML 파일이있는 경우 : 당신은 적어도 두 개의 소수 자리를 얻기 위해이 같은 XSLT와 숫자를 변환 할 수 있습니다

<?xml version="1.0" encoding="ISO-8859-1"?> 
<catalog> 
     <price>54.2</price> 
     <price>54.23</price> 
     <price>54.234</price> 
     <price>54.234567</price> 
</catalog> 

<?xml version="1.0" encoding="ISO-8859-1"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 

<xsl:template match="/"> 
    <html> 
    <body> 
     <xsl:for-each select="/catalog/price"> 
      <xsl:value-of select='format-number(., "#.00##########")'/><br /> 
     </xsl:for-each> 
    </body> 
    </html> 
</xsl:template> 
</xsl:stylesheet> 

이어서 출력 :

54.20 
54.23 
54.234 
54.234567