[jdom-interest] A utility Element subclass and a request for API extension

Elliotte Rusty Harold elharo at metalab.unc.edu
Mon Mar 25 07:28:27 PST 2002


One thing that hasn't been addressed in this thread, at least not 
this time around: Converting primitive data types to strings is not a 
trivial operation. It requires careful consideration of the needs of 
the local environment, particularly with regard to 
internationalization. Java is perhaps the first major programming 
language to recognize this. It has rather sophisticated facilities 
for localized conversions and formatting.

For example, what string should a boolean true be converted to? 
"true"? "TRUE"? "1"? "vrai"? "verdad"? "allineare"? "zutreffend"? 
something else?

How about the floating point number for pi? "3.1415292", "3 1415292" 
or "3,1415292"?

Integers are the only types that can perhaps be reliably converted, 
but even that's shaky. The number 72 would look very different in 
Egypt where they use real Arabic digits. Negative seventy-two could 
be -72 or (72) depending on context.

This is all very tricky. I don't think the JDOM project wants to be 
in the business of figuring out how to make these conversions and 
addressing all the important issues of localization and 
internationalization, especially when the Java class library already 
provides excellent support for these operations in a fully 
localizable way.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list