Solved

Replace function in XSLT

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

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.
Ravi

i have string like
0
Comment
Question by:mu_ravi1
[X]
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
9 Comments
 
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'), ',' ' ')" />
0
 
LVL 60

Accepted Solution

by:
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:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     version="1.0">
    <xsl:decimal-format name="my-format" grouping-separator=" "/>
    <xsl:template match="test">
        <MarketValue>
            <xsl:text disable-output-escaping="yes">R </xsl:text><xsl:value-of select="format-number(MarketValue,'# ##0.00', 'my-format')" />
        </MarketValue>
    </xsl:template>
</xsl:stylesheet>

Open in new window

0
 

Author Comment

by:mu_ravi1
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="http://www.w3.org/1999/XSL/Transform" xmlns:xasp="urn:myextension">
  <xsl:output method="xml"/>
  <xsl:template match="/Data/PortfolioCollection">
    <GridViewData>
      <xsl:for-each select="UTPortfolio">
        <ListData>
          <FundName>
            <xsl:value-of select="xasp:GetFundMapping(FundName)" />
          </FundName>
          <FundClass>
            <xsl:value-of select="FundClass" />
          </FundClass>
          <PriceDate>
            <xsl:value-of select="xasp:ConvertDateFormat(PriceDate)" />
          </PriceDate>
          <NAV>
            R <xsl:value-of select="format-number(NAV,'# ##0.00')" />
          </NAV>
          <MarketValue>
            <xsl:text disable-output-escaping="yes">R </xsl:text><xsl:value-of select="format-number(MarketValue,'# ##0.00')" />
          </MarketValue>
          <NoOfInvestor>
            <xsl:value-of select="NoOfInvestor" />
          </NoOfInvestor>
        </ListData>
      </xsl:for-each>
    </GridViewData>
  </xsl:template>
-------------------------
pls modify the above xslt and send me .
pls it is very urgent.
Thanks
0
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
0
 

Author Comment

by:mu_ravi1
ID: 34216884
Hi Gertone

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

Expert Comment

by:Geert Bormans
ID: 34216899
welcome
0
 

Author Comment

by:mu_ravi1
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
Ravi
0
 
LVL 60

Expert Comment

by:Geert Bormans
ID: 34217009
you can find my contact details in my profile
http://www.experts-exchange.com/M_3538911.html

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

Author Closing Comment

by:mu_ravi1
ID: 34217129
excellent and amazing
0

Featured Post

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!

Question has a verified solution.

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

Suggested Solutions

Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

756 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