You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cocoon.apache.org by Ferran Urgell <fe...@hotmail.com> on 2002/04/02 11:17:56 UTC
Transformation comma-point
Hi Cocooners!
I've a problem:
I'm getting xml from a database, but I'm getting some results (number results with decimals), but these results are in commas (ex. 123,34).
Now I'm trying to make some transformation into svg, but don't accept the commas....
I need to change this commas to points...
The question is: How I can do this ?
Thanks
Ferran Urgell
Re: Transformation comma-point
Posted by Nicola Ken Barozzi <ni...@apache.org>.
I call this template to substitute ' with \' for javascripts.
You can change it to make it substitute other chars.
How I call it:
<xsl:call-template name="fixQuotes">
<xsl:with-param name="do.quote">'</xsl:with-param>
<xsl:with-param name="string"><xsl:value-of select="."/></xsl:with-param>
</xsl:call-template>
The template:
<xsl:template name="fixQuotes">
<xsl:param name="do.quote"/>
<xsl:param name="string"/>
<xsl:choose>
<xsl:when test="$do.quote">
<xsl:choose>
<xsl:when test="contains($string, "'")">
<xsl:value-of
select="substring-before($string, "'")"/>
<xsl:text>\'</xsl:text>
<xsl:call-template name="fixQuotes">
<xsl:with-param name="do.quote" select="$do.quote"/>
<xsl:with-param name="string"
select="substring-after($string, "'")"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$string"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
--
Nicola Ken Barozzi nicolaken@apache.org
- verba volant, scripta manent -
(discussions get forgotten, just code remains)
---------------------------------------------------------------------
----- Original Message -----
From: Ferran Urgell
To: cocoon-users@xml.apache.org
Sent: Tuesday, April 02, 2002 11:17 AM
Subject: Transformation comma-point
Hi Cocooners!
I've a problem:
I'm getting xml from a database, but I'm getting some results (number
results with decimals), but these results are in commas (ex. 123,34).
Now I'm trying to make some transformation into svg, but don't accept the
commas....
I need to change this commas to points...
The question is: How I can do this ?
Thanks
Ferran Urgell
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
Re: Transformation comma-point
Posted by Ferran Urgell <fe...@hotmail.com>.
There are some function in xsl to transform commas into points ?
----- Original Message -----
From: Nader S. Henein
To: cocoon-users@xml.apache.org
Sent: Tuesday, April 02, 2002 11:25 AM
Subject: RE: Transformation comma-point
you can use a regular expression witch changes comas between numeric characters into "." but this
will affect you if you have something like 1,2,3,4 in a textual context as opposed to numerical.
-----Original Message-----
From: Ferran Urgell [mailto:ferran_urgell@hotmail.com]
Sent: Tuesday, April 02, 2002 1:18 PM
To: cocoon-users@xml.apache.org
Subject: Transformation comma-point
Hi Cocooners!
I've a problem:
I'm getting xml from a database, but I'm getting some results (number results with decimals), but these results are in commas (ex. 123,34).
Now I'm trying to make some transformation into svg, but don't accept the commas....
I need to change this commas to points...
The question is: How I can do this ?
Thanks
Ferran Urgell
RE: Transformation comma-point
Posted by "Nader S. Henein" <ns...@bayt.net>.
you can use a regular expression witch changes comas between numeric
characters into "." but this
will affect you if you have something like 1,2,3,4 in a textual context as
opposed to numerical.
-----Original Message-----
From: Ferran Urgell [mailto:ferran_urgell@hotmail.com]
Sent: Tuesday, April 02, 2002 1:18 PM
To: cocoon-users@xml.apache.org
Subject: Transformation comma-point
Hi Cocooners!
I've a problem:
I'm getting xml from a database, but I'm getting some results (number
results with decimals), but these results are in commas (ex. 123,34).
Now I'm trying to make some transformation into svg, but don't accept the
commas....
I need to change this commas to points...
The question is: How I can do this ?
Thanks
Ferran Urgell
Re: Transformation comma-point
Posted by KOZLOV Roman <r-...@opencascade.com>.
Hello,
It is also possible to use translate function like this:
<xsl:value-of select="translate($strToFormat, ',', '.')"/>
Best regards
Roman
Luca Morandini wrote:
> Ferran,
>
> one elegant way could be:
>
> 1) Define your format for numbers
>
> <xsl:decimal-format
> name="italy"
> decimal-separator=","
> grouping-separator="."
> NaN="vuoto"
> />
>
> 1) Apply it to the outputted numbers
>
> <xsl:value-of select="format-number(sql:pay, '###.###.##0,000', 'italy')"/>
>
> Of course, I used this for the opposite reason (outputting commas instead of
> points)... but you got the idea :)
>
> Best regards,
>
> P.S.
> Next time use plain text, please.
>
> ---------------------------------------------
> Luca Morandini
> GIS Consultant
> lmorandini@ieee.org
> http://utenti.tripod.it/lmorandini/index.html
> ---------------------------------------------
>
> -----Original Message-----
> From: Ferran Urgell [mailto:ferran_urgell@hotmail.com]
> Sent: Tuesday, April 02, 2002 11:18 AM
> To: cocoon-users@xml.apache.org
> Subject: Transformation comma-point
>
> Hi Cocooners!
>
> I've a problem:
> I'm getting xml from a database, but I'm getting some results (number
> results with decimals), but these results are in commas (ex. 123,34).
>
> Now I'm trying to make some transformation into svg, but don't accept the
> commas....
> I need to change this commas to points...
>
> The question is: How I can do this ?
>
> Thanks
>
> Ferran Urgell
>
> ---------------------------------------------------------------------
> Please check that your question has not already been answered in the
> FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
>
> To unsubscribe, e-mail: <co...@xml.apache.org>
> For additional commands, e-mail: <co...@xml.apache.org>
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>
RE: Transformation comma-point
Posted by Luca Morandini <lu...@tin.it>.
Ferran,
one elegant way could be:
1) Define your format for numbers
<xsl:decimal-format
name="italy"
decimal-separator=","
grouping-separator="."
NaN="vuoto"
/>
1) Apply it to the outputted numbers
<xsl:value-of select="format-number(sql:pay, '###.###.##0,000', 'italy')"/>
Of course, I used this for the opposite reason (outputting commas instead of
points)... but you got the idea :)
Best regards,
P.S.
Next time use plain text, please.
---------------------------------------------
Luca Morandini
GIS Consultant
lmorandini@ieee.org
http://utenti.tripod.it/lmorandini/index.html
---------------------------------------------
-----Original Message-----
From: Ferran Urgell [mailto:ferran_urgell@hotmail.com]
Sent: Tuesday, April 02, 2002 11:18 AM
To: cocoon-users@xml.apache.org
Subject: Transformation comma-point
Hi Cocooners!
I've a problem:
I'm getting xml from a database, but I'm getting some results (number
results with decimals), but these results are in commas (ex. 123,34).
Now I'm trying to make some transformation into svg, but don't accept the
commas....
I need to change this commas to points...
The question is: How I can do this ?
Thanks
Ferran Urgell
---------------------------------------------------------------------
Please check that your question has not already been answered in the
FAQ before posting. <http://xml.apache.org/cocoon/faqs.html>
To unsubscribe, e-mail: <co...@xml.apache.org>
For additional commands, e-mail: <co...@xml.apache.org>