Replace function in XSLT

Posted on 2010-11-26
Last Modified: 2013-11-18
from xslt iam using
            <xsl:text disable-output-escaping="yes">R </xsl:text><xsl:value-of select="format-number(MarketValue,'#,##0.00')" />

This will give the result in the form of    R 67,373,229.85.

Now i need to replace the comma with space in the above string.
pls give me the code for the above requirement.

i have string like
Question by:mu_ravi1
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
LVL 60

Expert Comment

by:Geert Bormans
ID: 34216368
<xsl:value-of select="format-number(MarketValue,'#,##0.00')" />
to become
<xsl:value-of select="translate(format-number(MarketValue,'#,##0.00'), ',' ' ')" />
LVL 60

Accepted Solution

Geert Bormans earned 500 total points
ID: 34216389
The proper way however would be to make the space an active character by means of a named xsl:decimal-format
if you make the space the grouping seperator, you can directly use that

<?xml version="1.0" encoding="UTF-8"?>
    <xsl:decimal-format name="my-format" grouping-separator=" "/>
    <xsl:template match="test">
            <xsl:text disable-output-escaping="yes">R </xsl:text><xsl:value-of select="format-number(MarketValue,'# ##0.00', 'my-format')" />

Open in new window


Author Comment

ID: 34216441

it is giving errors.
iam sending my xslt file .
pls modify the xslt and send me.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY nbsp "&#160;">
<xsl:stylesheet version="1.0" xmlns:xsl="" xmlns:xasp="urn:myextension">
  <xsl:output method="xml"/>
  <xsl:template match="/Data/PortfolioCollection">
      <xsl:for-each select="UTPortfolio">
            <xsl:value-of select="xasp:GetFundMapping(FundName)" />
            <xsl:value-of select="FundClass" />
            <xsl:value-of select="xasp:ConvertDateFormat(PriceDate)" />
            R <xsl:value-of select="format-number(NAV,'# ##0.00')" />
            <xsl:text disable-output-escaping="yes">R </xsl:text><xsl:value-of select="format-number(MarketValue,'# ##0.00')" />
            <xsl:value-of select="NoOfInvestor" />
pls modify the above xslt and send me .
pls it is very urgent.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 60

Expert Comment

by:Geert Bormans
ID: 34216473
please look carefully at the xml I sent
there is decimal-format definition, you need to copy that
    <xsl:decimal-format name="my-format" grouping-separator=" "/>
and reference it as I showed in my XSLT

I have two comments with your reply
1. You did not do what I suggested, of course there are errors
2. It would help if you told at least what the error was you are experiencing.

Please do some small effort yourself of integrating my suggestion with your code

Author Comment

ID: 34216884
Hi Gertone

hates of to ur solution.
It works perfectly.
thank u very much
LVL 60

Expert Comment

by:Geert Bormans
ID: 34216899

Author Comment

ID: 34216974
Hi Gertone

may i know ur details.
U are technically very sound.
iam from india.
iam working as programmer in india.
With Regards
LVL 60

Expert Comment

by:Geert Bormans
ID: 34217009
you can find my contact details in my profile

my web reference is there,
my email as well, but you need to make
[at] an "@"
[dot] a "."

Author Closing Comment

ID: 34217129
excellent and amazing

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL several years ago, it seemed like now was a good time to update it for object-oriented PHP.  This article does that, replacing as much as possible the pr…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question