[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XSL : Numbers to Words

Subject: RE: XSL : Numbers to Words
From: "Passin, Tom" <tpassin@xxxxxxxxxxxx>
Date: Thu, 22 Apr 2004 17:25:29 -0400
numbers to words
> From: Renganat Krishnan [mailto:renganat_krishnan@xxxxxxxxx] 
> 
> I was wondering if anyone has acheived this
> 
> Converting a number to Words in XSL. 
> 
> Xample
> 
> <a>
>  <num>10000</num>
> </a>
>  output from xsl on this xml should be
> <a>
>  <numInWords>ten thousand</numInWords>
> </a>
> 

If you want to be able to translate any kind of number of any size, I
think it would be pretty hard.  But if the range and type of the numbers
were constrained to some degree it should be feasible.   Say you know
that you will be dealing with only integers smaller than 100,000.  You
would use lookup tables to get the right words.  I have done something
like this to create (quasi!)natural language driving directions from a
set of turn-by-turn data (e.g., "at the intersection with I-95 bear left
onto Rt. 50S").

I have also done a bit of work getting graphs (like bar charts) to
auto-scale, and this seems similar as well - you work out the right
tests, and index into a lookup table using the test results.  The lookup
table can either be embedded into the stylesheet or it can be an
external xml file.

I'm sure it is feasible, as long as the range is restricted in some kind
of sensible fashion.  You will probably want to get familiar with
recursive templates.

Cheers,

Tom P

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.