[xsl] Best way to format currencies

Subject: [xsl] Best way to format currencies
From: Kaine Varley <kaine.varley@xxxxxxxxxxxx>
Date: Thu, 16 Oct 2003 09:39:44 +0100
Hi all,

I was wondering if anyone has any opinions over the best way of formatting
currencies? My ideas were use the format-number() method together with a
format string, for instance, I am proposing the following XML internally,
and began to question if this is the best approach:

<Data TotalRows="4">
    <ColumnHeading Number="1">Cost</ColumnHeading>
    <ColumnHeading Number="2">Item</ColumnHeading>
    <Row Number="1">
      <Column Number="1" Type="Currency" Format="£#,##0.00">23.32</Column>
      <Column Number="2" Type="Standard">Golf Clubs</Column>
    <Row Number="2">
      <Column Number="1" Type="Currency" Format="$#,##0.00">10</Column>
      <Column Number="2" Type="Standard">Jumpsuit</Column>
    <Row Number="3">
      <Column Number="1" Type="Currency" Format="€#,##0.00">20.0235</Column>
      <Column Number="2" Type="Standard">Shoes</Column>
    <Row Number="4">
      <Column Number="1" Type="Currency">20.65</Column>
      <Column Number="2" Type="Standard">Toy Car</Column>

I was hoping to check for the format attribute on columns whose Type is
'Currency', to override a built-in format pattern (that I decided), viz.:

	format-number(., @Format)

However, recent discussion threads (see 'Problems transforming currency
values using British pound (£) and Euro (€) signs') have lead me to question
my technique, since it may not be good practice to include the currency
symbol in the format pattern. So, I was wondering if anyone has any thoughts
or opinions on which way would be their ideal way to cope with currencies
that may assume different formats, and potentially use unusual or special
characters, such as the British pound sign(£).

In particular, I would like answers to the following questions:

When creating currencies formats what would be the best approach:

- Format the number then apply rules to concatenate any currency symbol(s) 
  to either front or back?
- Format the number including the currency symbol(s) in the format pattern 
  and let the format-number() function take care of the everything? (As 
  described above)
- Format the currency before processing the XSLT?
- None of the above, there's a much better way?

Also, would the use of the xsl:decimal-format have any influence over your
ideal solution?

Thanks in advance for your ideas.


PROACTIS Group Limited
Holtby Manor, Stamford Bridge Road, York, YO19 5LL
Tel +44 (0)1904 481999 Fax +44 (0)1904 481666
Visit us at www.proactis.com <http://www.proactis.com/> 

PROACTIS ® - Control spend.  Streamline purchasing.

The information contained in this email is intended only for the individual
to whom it is addresses.  It may contain privileged and confidential
information.  If you have received this message in error or there are any
problems, please notify the sender immediately and delete the message from
your computer.  The unauthorised use, disclosure, copying or alteration of
this message is forbidden.  PROACTIS Group Limited will not be liable for
direct, special, indirect or consequential damage as a result of any virus
being passed on, or arising from alteration of the content of this message
by a third party.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread