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

Re: Best way to represent fractional values?


fractional number
On Mon, Feb 10, 2003 at 01:51:51PM -0500, Chiusano Joseph wrote:
><Snip>
>What you suggest would limit me to 0.33
></Snip>
>
>Not at all, if you make fractionDigits greater than 2.

Which continues the restriction.  It *still* never represents a "repeating
decimal".  Lisp calls these (I think mathematically correctly) rational
numbers, and they are a data type, not an expression.  It's perfectly
reasonable to want to preserve this information, instead of throwing it away
immediately.  It's not supported by W3C XML Schema, though.

Several possibilities exist:

1. make it a structured thing, as proposed:
<rational><numerator>1</numerator><denominator>3</denominator></rational>

Boy, oh boy.  Makes one wish it were possible to derive from anySimpleType,
huh?

2. write it as a regex:
<rational>\d+/\d+</rational>

Nicer, but there's no way to know it has numeric semantics, which is much of
the point of having a type system in the first place (if only XML *had* a
type system, instead of a collection of collections of types).

3. write it as a list:
<rational>1 3</rational>

You want to constrain the maxLength and minLength facets, and make it a list
of Integer in all likelihood.  This still doesn't have the right semantics,
but it does identify each of the particles as a numeric frob.

4. develop a type library for XML based on theory, not on horse-trading, and
systematic rather than shapeless bag of bags

There are some quite nice mathematical theories running around for the
numeric parts, some of which, as I understand it, are quite mature.  Being
able to say that a number is-a number would be a pleasant thing.  Typing of
things that aren't numbers, such as strings, BLOBs, dates, or grues, is at a
perhaps significantly less mature state of development, but applying a
theory, *any* theory, might prove at least an interesting contrast.

Amy!
-- 
Amelia A. Lewis                    amyzing {at} talsever.com
Boxing is a lot like ballet, except that they don't dance, there isn't
any music, and they hit each other.

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.