xml - XSLT Formatting number gives wrong thousand an grouping separator -


i have xslt page, needs become regional aware. pass thousand , decimal separator session parameters page. put them in xsl:decimal-format , try call on amount fields.

    <xsl:param name="usernumberformat"/>     <xsl:param name="userthousandseparator"/>     <xsl:param name="userdecimalseparator"/>     <xsl:decimal-format nan="" decimal-separator="$userdecimalseparator" grouping-separator="$userthousandseparator" name="userformat"/>     ...     <xsl:value-of select="format-number(number(payment:instructedamount/system:amount), '#,###.00', 'userformat')"/> 

but have problem when deploy, characters wrong formatted.

for example instructed amount field gets following input: 0.12

my thousand separator comma , decimal separator dot.

but gives output: 00,.

i tested session variables $userdecimalseparator , $userthousandseparator printing them out on page hard coded , values correctly. doing wrong?

you cannot use variable in of xsl:decimal-format's attributes.

predefine several xsl:decimal-format elements, , use parameter select 1 of them name.


added example:

<xsl:stylesheet version="1.0"  xmlns:xsl="http://www.w3.org/1999/xsl/transform"> <xsl:output method="xml" version="1.0" encoding="utf-8" indent="yes"/>  <xsl:param name="decimal-format">eu</xsl:param>  <xsl:decimal-format name="us" decimal-separator="." grouping-separator="," /> <xsl:decimal-format name="eu" decimal-separator="," grouping-separator="." /> <xsl:variable name="decimal-format-pattern">     <xsl:choose>         <xsl:when test="$decimal-format='us'">#,###.00</xsl:when>         <xsl:when test="$decimal-format='eu'">#.###,00</xsl:when>     </xsl:choose> </xsl:variable>  <xsl:template match="/">     <xsl:value-of select="format-number(1234.567, $decimal-format-pattern, $decimal-format)"/>   </xsl:template>  </xsl:stylesheet> 

this return 1,234.57 when num-format parameter "us", , 1.234,57 when parameter "eu".

note pattern argument of format-number() function interpreted according decimal-format in use - must parametrized.


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -