xsl-list
[Top] [All Lists]

Re: Formating numbers

2004-05-31 08:39:44
Ok. Thanks for the help of Michael & Jeff.

Here is the final code

[XML]
<items>
 <item>
  <money>1000</money>
 </item>
 <item>
  <money>999</money>
 </item>
 <item>
  <money>1000000,11</money>
 </item>
 <item>
  <money>123,4567</money>
 </item>
 <item>
  <money>123456789123456,4567</money>
 </item>
</items>

and the XSL

[XSL]

<xsl:stylesheet xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"; =
version=3D"1.0">
 <xsl:decimal-format name=3D"formato" decimal-separator=3D"," =
grouping-separator=3D"."/>
 <xsl:template match=3D"/">
  <xsl:for-each select=3D"//item">
   <xsl:text> ___ </xsl:text>
   <xsl:value-of =
select=3D"format-number(translate(money,',','.'),'#.###,##', =
'formato')"/>
  </xsl:for-each>
 </xsl:template>
</xsl:stylesheet>



and......yes.... I had to translate the information (In Spain, the=20

decimal separator is a comma (","). So, I had used "translate"



--------------------------

----- Original Message ----- 
From: "Michael Kay" <mhk(_at_)mhk(_dot_)me(_dot_)uk>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Monday, May 31, 2004 4:48 PM
Subject: RE: [xsl] Formating numbers



I have several cells in my xsl with numbers (from
a XML), but these numbers aren't formatted

If they aren't formatted at all, you've got problems, but if they follow the
examples below, you can use translate() to convert "," to "." and "." to "":

translate($x, ",.", ".")

You can then use format-number() to produce any output form for the numbers
that you like.

Michael Kay



For example (because the information
are transaction banks)

1000000 instead of 1.000.000

1687,35 instead of 1.687,35

Do you know a funtion to "format" the original number into
a "well-formed" number?


Thanks
------------------------------------------------------------------
This e-mail and the documents attached are confidential and
intended solely
for the addressee; it may also be privileged. If you receive
this e-mail
in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos
Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network,
the sender does
not warrant that this transmission is virus-free and will not
be liable for
any damages resulting from any virus transmitted.

"Este mensaje y los ficheros adjuntos pueden contener información
confidencial destinada solamente a la(s) persona(s) mencionadas
anteriormente. Pueden estar protegidos por secreto
profesional Si usted
recibe este correo electrónico por error, gracias de informar
inmediatamente
al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos
Origin no se hace responsable por su contenido. Su contenido
no constituye
ningún compromiso para el grupo Atos Origin, salvo
ratificación escrita por
ambas partes.
"Aunque se esfuerza al máximo por mantener su red libre de
virus, el emisor
no puede garantizar nada al respecto y no será responsable de
cualesquiera
daños que puedan resultar de una transmisión de virus"
------------------------------------------------------------------

--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--





--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--+--

-----------------------------------------------------------------
This e-mail and the documents attached are confidential and intended solely
for the addressee; it may also be privileged. If you receive this e-mail
in error, please notify the sender immediately and destroy it.
As its integrity cannot be secured on the Internet, the Atos Origin group
liability cannot be triggered for the message content. Although the
sender endeavours to maintain a computer virus-free network, the sender does
not warrant that this transmission is virus-free and will not be liable for
any damages resulting from any virus transmitted.

"Este mensaje y los ficheros adjuntos pueden contener información
confidencial destinada solamente a la(s) persona(s) mencionadas
anteriormente. Pueden estar protegidos por secreto profesional Si usted
recibe este correo electrónico por error, gracias de informar inmediatamente
al remitente y destruir el mensaje.
Al no estar asegurada la integridad de este mensaje sobre la red, Atos
Origin no se hace responsable por su contenido. Su contenido no constituye
ningún compromiso para el grupo Atos Origin, salvo ratificación escrita por
ambas partes.
"Aunque se esfuerza al máximo por mantener su red libre de virus, el emisor
no puede garantizar nada al respecto y no será responsable de cualesquiera
daños que puedan resultar de una transmisión de virus"
------------------------------------------------------------------


<Prev in Thread] Current Thread [Next in Thread>
  • Re: Formating numbers, Antonio Santos <=