Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
| Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old August 26th, 2008, 12:59 AM
Authorized User
Points: 166, Level: 3
Points: 166, Level: 3 Points: 166, Level: 3 Points: 166, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2008
Location: , , .
Posts: 37
Thanks: 0
Thanked 0 Times in 0 Posts
Default Can XSLT convert amount to words

Hi,

I am using XSLT 1.0. In the report i have a requirement to display the amount in to words. Can anyone tell me whether it is possible to do this in XSLT.



  #2 (permalink)  
Old August 26th, 2008, 01:50 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

I've no doubt it is possible, as most things are.

There isn't any built in feature to allow you to do this, but I'm sure a template could be written to convert a number into words. This template probably wouldn't be simple however.



/- Sam Judson : Wrox Technical Editor -/
  #3 (permalink)  
Old August 26th, 2008, 03:09 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There is no standard facility in XSLT 1.0 to do this. It is available as an extension in at least one XSLT 1.0 processor (Saxon); apart from that, you will have to call out to an external library.

XSLT 2.0 has this capability as standard:

<xsl:number value="1234" format="w" lang="en"/>

outputs something like "one thousand two hundred and thirty four"



Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
  #4 (permalink)  
Old January 10th, 2018, 03:20 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2018
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Michael, i have used
<xsl:number value="1234" format="w" lang="en"/> and is working for me.

I need to convert the test in spanish language, so tried the below


<xsl:number value="1234" format="w" lang="es"/>, but still i am getting results in english language.

Can you help on this?
  #5 (permalink)  
Old January 10th, 2018, 04:09 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

The question of which languages are supported depends on the XSLT processor you are using.

If you're using Saxon, then it depends on which version & edition: please raise Saxon-specific questions on the Saxon help forums at saxonica.plan.io.

If you're using a different XSLT 2.0 processor, e.g. IBM or Altova, please contact the respective vendor.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Currency To Words Kenny Alligood Access 3 October 12th, 2017 06:00 AM
Subject: Convert XML using XSLT manoj1984 XSLT 6 May 30th, 2008 04:27 PM
Convert Numbers to Words hasankelepir Classic ASP Basics 5 October 1st, 2007 07:15 AM
XSLT - Convert the date in different format haixia XSLT 1 August 25th, 2006 11:51 AM
convert number into words on acces form superparim Wrox Book Feedback 0 September 19th, 2005 01:55 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.