Re: $ and Commas - How do we parse these out of data
As a matter of design, having the dollar signs within the XML is less
than ideal. This is because those numbers (i.e., "TOTAL" and the
second "LIMIT") are no longer numbers, they're strings. As such,
format-number won't work. Furthermore, dollar signs are for display
only and not really part of the "data." That's what something like
format-number is for. This same kind of problem is evident when
calculations (you can't do math with a string) come into play.
That said, I would first try and modify the XML to get rid of the
dollar signs. If you can, then you're in good shape. Change the XML
and use format-number.
If not, and I suspect this is probably the case, then you'll first
need to use string manipulation to get rid of the dollar sign (that
should be pretty simple). In other words, get rid of the dollar sign
(you can keep the commas). Then, use format-number *after* you've
converted the string (i.e., your numbers with dollar signs) to a
Here's an example that does it both ways.
<!-- Easy way -->
<xsl:value-of select="format-number(./First, '$##,###.##')"/>
<!-- Less easy way -->
The "Easy way" simply takes the "First" element and formats it.
The "Less easy way" first converts the "Second" element by stripping
off the dollar sign, then apply the formatting. If you're not 100%
sure if there will be a dollar sign, then you'll need to check using
something like "starts-with" in a conditional.
Hope this helps.
--- In XSL-FO@y..., sg_goli@y... wrote:
> I have an XML file which has the following data.
> How do i check these elements and parse out the punctuation in
> XML and apply my own formatting and display using XSL.