[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

XSLT: What's wrong with <xsl:value-of select="format-number(Amount, "##.##")" />

Posted on 2004-11-01
6
Medium Priority
?
445 Views
Last Modified: 2008-02-01
I have the following data:

<Amount>40.0</Amount>

I want to display it as:

40.00

Using something along the lines of:

<xsl:value-of select="format-number(Amount, "##.##")" />

I get "XML Parsing Error: not well-formed" in Firefox. I can find examples where it shows the value of an attribute in this way or for a fixed value, but not the contents of a tag.
0
Comment
Question by:tjrobinson
[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
  • 3
  • 2
6 Comments
 
LVL 52

Assisted Solution

by:Carl Tawn
Carl Tawn earned 1000 total points
ID: 12461624
Try:

<xsl:value-of select="format-number(Amount, '##.##')" />
0
 

Author Comment

by:tjrobinson
ID: 12461674
That stops the error but I get an output of:

40

Probably something to do with the format parameter, I need to force the decimal places.
0
 
LVL 21

Accepted Solution

by:
MogalManic earned 1000 total points
ID: 12461684
Try:

<xsl:value-of select="format-number(Amount, '#0.00')" />

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:tjrobinson
ID: 12461701
Thanks that works well. I've split the points between you, but before you go is there any way of stopping it displaying if it's non a number (NaN)?
0
 
LVL 21

Expert Comment

by:MogalManic
ID: 12461821
<xsl:choose>
  <xsl:when test='String(Number(Amount))="NaN"'>
          0.00
  </xsl:when>
  <xsl:otherwise>
     <xsl:value-of select="format-number(Amount, '#0.00')" />
  </xsl:otherwise>
</xsl:choose
0
 

Author Comment

by:tjrobinson
ID: 12461824
Thanks, that looks just the job.
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

649 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