2016-11-02 6 views
0

xslt format-numberを使ってローカル番号をフォーマットしようとしました。私はこの出力を得ることができませんでした。XSLTローカル番号書式

1 
10 
100 
1,000 
10,000 
1,00,000 
10,00,000 
1,00,00,000 
10,00,00,000 

XSLTを使用します。

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="text"/> 
<xsl:variable name="t">123590</xsl:variable> 
<xsl:template match="/"> 
<xsl:value-of select="format-number($t, '##,##,##0')"/> 
</xsl:template> 
</xsl:stylesheet> 

ありがとうございました。コピー Umesh

+0

私はこれをhttp://fiddle.frameless.io/に入れてもうまく動作し、 '1,23,590'を出力するので、あなたの問題は特定のXSLTプロセッサに関連しているようです。 – Lucero

+1

参照:http://stackoverflow.com/a/38643507/3016153 –

+0

[XSLT書式番号とインディアン価格のカンマを含む]重複している可能性があります(http://stackoverflow.com/questions/38641504/xslt-format-number-コンマ - インディアン価格で) –

答えて

0

XSLT format-number with comma for indian price


フロートと整数INR番号形式XSLT

<?xml version="1.0" encoding="UTF-8"?> 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
<xsl:output method="html"/> 
<xsl:variable name="Value">301050101</xsl:variable> 
<xsl:template match="/"> 

     <!-- 1 
10 
100 
1,000 
10,000 
1,00,000 
10,00,000 
1,00,00,000 
10,00,00,000 --> 

    <xsl:choose> 
     <xsl:when test="contains($Value,'.')"> 
      <xsl:variable name="integerValue" select="substring-before($Value,'.')"/> 
      <xsl:variable name="floatValue" select="substring-after($Value,'.')"/> 
      <!--    <xsl:value-of select="$integerValue"/> 
      <xsl:value-of select="$floatValue"/> --> 
      <xsl:call-template name="INR_Number_Format"> 
       <xsl:with-param name="integerValue" select="$integerValue"/> 
      </xsl:call-template> 
      <xsl:text>.</xsl:text> 
      <xsl:value-of select="$floatValue"/> 
     </xsl:when> 
     <xsl:otherwise> 
      <xsl:call-template name="INR_Number_Format"> 
       <xsl:with-param name="integerValue" select="$Value"/> 
      </xsl:call-template> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 

<xsl:template name="INR_Number_Format"> 
    <xsl:param name="integerValue"/> 
    <xsl:choose> 
     <xsl:when test="$integerValue >= 1000"> 
      <xsl:value-of select="format-number(floor($integerValue div 1000), '#,##')" /> 
      <xsl:text>,</xsl:text> 
      <xsl:value-of select="format-number($integerValue mod 1000, '000')" /> 
     </xsl:when> 
     <xsl:otherwise> 
      <xsl:value-of select="format-number($integerValue, '#,###')" /> 
     </xsl:otherwise> 
    </xsl:choose> 
</xsl:template> 

は、それが:)をお役に立てば幸いです。