[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

AW: Formatting of numbers, dynamically

Subject: AW: Formatting of numbers, dynamically
From: "Braumuller, Hans" <h.braumueller@xxxxxxxxxxxx>
Date: Thu, 14 Mar 2002 12:14:16 +0100
xsl format string
Hello,

i applied the sugestions to format the numbers dynamically with the
following source :

<root>
    <number minor_unit="2">1.126</number>
    <number minor_unit="2">1.000</number>
    <number minor_unit="2">0.120</number>
    <number minor_unit="2">12999999999</number>
 </root>

and i get the output:

#,##0.00
1.13
#,##0.00
1.00
#,##0.00
0.12
#,##0.00
12,999,999,999.00
 

I have two questions about it:

1.How can i convert it to following number format
12.999.999.999,00
(exchanging point with comma)
 
2. How can i elimante from the output these 
#,##0.00

Please excuse my insufficient knowledge about xslt. 

Thanks,

Hans Braumuller
Networking Artist
http://crosses.net



> -----Ursprungliche Nachricht-----
> Von: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx]Im Auftrag von David B.
> Bitton
> Gesendet: Dienstag, 12. Marz 2002 22:40
> An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Betreff: Re:  Formatting of numbers, dynamically
> 
> 
> I modified the code slightly:
> 
> <xsl:variable name="format-string">
> 	<xsl:text>#,##0</xsl:text>
> 	<xsl:choose>
> 		<xsl:when test="$currency_code/@minor_unit > 0">
> 			<xsl:text>.</xsl:text>
> 			<xsl:call-template name="minor_unit">
> 				<xsl:with-param 
> name="minor_unit" select="$currency_code/@minor_unit"/>
> 			</xsl:call-template>
> 		</xsl:when>
> 	</xsl:choose>
> </xsl:variable>
> 
> I just added the xsl:choose because I was getting a decimal 
> point when minor_unit was zero (for Yen for example).
> Thanks again, and if you are ever in NYC, I owe you a beer.
> 
> On Mon, Mar 11, 2002 at 11:21:26PM +0100, Joerg Heinicke wrote:
> > Here we need again recursive template: counting down the 
> @minor_unit, for
> > every processing of the template 'minor_unit' one '0'.
> > 
> > the XML
> > 
> > <root>
> >     <number minor_unit="3">1.123</number>
> >     <number minor_unit="2">1.000</number>
> >     <number minor_unit="4">0.120</number>
> >     <number minor_unit="3">12</number>
> > </root>
> > 
> > the XSL:
> > <xsl:template match="number">
> >     <xsl:variable name="format-string">
> >         <xsl:text>#,##0.</xsl:text>
> >         <xsl:call-template name="minor_unit">
> >             <xsl:with-param name="minor_unit" select="@minor_unit"/>
> >         </xsl:call-template>
> >     </xsl:variable>
> >     <xsl:value-of select="$format-string"/><br/>
> >     <xsl:value-of select="format-number(., $format-string)"/><br/>
> > </xsl:template>
> > 
> > <xsl:template name="minor_unit">
> >     <xsl:param name="minor_unit" select="2"/>
> >     <xsl:text>0</xsl:text>
> >     <xsl:if test="$minor_unit > 1">
> >         <xsl:call-template name="minor_unit">
> >             <xsl:with-param name="minor_unit" 
> select="$minor_unit - 1"/>
> >         </xsl:call-template>
> >     </xsl:if>
> > </xsl:template>
> > 
> > the output:
> > #,##0.000
> > 1.123
> > #,##0.00
> > 1.00
> > #,##0.0000
> > 0.1200
> > #,##0.000
> > 12.000
> > 
> > Regards,
> > 
> > Joerg
> > 
> > > I am current using format-number($node, '#,##0.00') for formatting
> > currency.
> > > We are now implementing foreign currencies into our 
> application.  For
> > every
> > > transaction, I have an element, CurrencyCode, which 
> contains the ISO
> > > currencyCode and an attribute @minor_unit which tells me 
> how many digits
> > > follow the decimal seperator.  My question is how I can 
> dynamically build
> > > the formatting string.
> > >
> > > I was reading this morning in the March 2002 issue of 
> MSDN magazine about
> > > how XSLT is a "Functional programming language", and therefore
> > xsl:variable
> > > entities are "not really variables, rather 
> runtime-assigned constants"
> > > because once they are assigned, the values cannot be 
> changed.  So, this
> > lead
> > > me to start thinking about how I could wrap an 
> xsl:for-each with the
> > > xsl:variable element to produce my output.  What I don't 
> know if how to
> > > obtain functionality like:
> > >
> > > for(i=0;i<=@minor_unit;i++){ ... };
> > >
> > > I do not want to use an enbedded JScript solution because 
> I want the XSL
> > to
> > > be portable (namely between MSXML and Xalan).  So, how 
> would I construct
> > the
> > > @select attribute in the xsl:for-each to just loop a 
> predetermined number
> > of
> > > times?
> > >
> > > --
> > >
> > > David B. Bitton
> > > david@xxxxxxxxxxxxxx
> > > www.codenoevil.com
> > >
> > > Diversa ab illis virtute valemus.
> > 
> > 
> >  XSL-List info and archive:  
http://www.mulberrytech.com/xsl/xsl-list

-- 

David B. Bitton
david@xxxxxxxxxxxxxx

Diversa ab illis virtute valemus.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.