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

Re: Combining float/string to specify value/units

  • From: "Thomas B. Passin" <tpassin@h...>
  • To: xml-dev@l...
  • Date: Mon, 26 Mar 2001 00:29:31 -0500

float string
Steve Rosenberry asks -

>
> Is it possible to derive an attribute type from a float primitive with
> an appended string indicating the physical units associated with the
> value?  For example, I'd like to validate the following examples of
> attribute values:
>
>         12.0 seconds
>         1.11 msecs
>         3.05 mins
>
> as a float followed by a restricted enumeration of allowable time
> intervals.  If by chance, there is a time type that already does this,
> let me know, but specifying just time units isn't my only issue.  I'm
> interested in specifying any generic units i.e. db, knots, Hz, %'s (e.g.
> 10%) etc...
>
But "12.0 seconds" isn't a float.  It's a either a string or a type
compounded from a float and a string.  You can't derive a compound type from
a primitive (I'm assuming you are thinking about xml-schema data types),
since you can only restrict primitive types, not extend or compound them.

If it's a string whose first part looks like a string representation of a
float, by all means use a RE pattern.  Otherwise, add a separate attribute
to hold the units, then you can specify a floating point type independently
of the units. Adding the attribute would be the better plan, most likely.

Specifying units isn't necessarily as easy as it looks, since you might want
to get into the handling of compound units (e.g., kg/m^2-sec), and this will
potentially involve converting units to other forms. How much information
one wants to pass to the application about the units and how they should  be
represented can be hard if full generality is needed.  If course, I don't
know if that applies to your case or not.

Cheers,

Tom P


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.