[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: (091)xml-dev(093) What are units-of-measure? e.g.,what's a (q)kilome
costello@m...@INTERNET@wtgw'(Roger L. Costello) |If we grant that kilometer is a property/relation/function between |a distance dimension object and a number, then the choice of |representations would be: | | <River id="Yangtze"> | <length kilometers="6300"/> | </River> | |or alternatively: | | <River id="Yangtze"> | <length> | <kilometer>6300</kilometer> | </length> | </River> | |This is quite a radical approach. I am surprised that there |aren't more comments, since the "conventional wisdom" is |not to treat kilometer as a property/relation/function, but rather |to treat it as the value of a property, e.g., | | <River id="Yangtze"> | <length unit="kilometer">6300</length> | </River> | |Thoughts? /Roger In one of the systems I've designed which allow for units to be specified on properties, the 'units' attribute gave the name which was mapped to a object comprising integers representing the dimensionality of the numerator and denominator (bases being prime, eg length -> 2, time->5 so 2/25 is acceleration) and a real factor to convert to unit SI. As such this was treated as an additional property of the length property, and a seperate functions used it to do the conversion to and from other compatible units. No checks were provided against converting torque and energy in this system (both force times distance). Names were parsed for combinations of the predefined units in the implementation (eg "m/s2" is the combination of metres and 1/(seconds squared)). Names such as "D3/T:4.54" were also allowed (distance cubed per time, conversion factor 4.54) for units not in the implementation's map. In a functional language, the name 'kilometer' could be mapped to a function to convert to the basis units, but this may also require a second parameter for dimensionality to be passed around, depending on whether the language's type system could catch these. There would also be a need for a system to composite these functions for combinations of units. In terms of the use cases I've met, you have one property specified as having one value and one units label. The user wants the representation of the value and the units to be preserved in the persistent data; the underlying maths wants the value in SI (this is particularly true with degrees/radians, where floating point errors make 60 degrees->pi/3 radians->59.9999* degrees). The units attribute of the property carries the dimensionality and conversion factor for the value, comparisons are made first to check that the units are equal, if so the value are compared, if not then the values are converted to a common units then compared. Doing such a comparison where the value in different units is in differently named attributes or elements would be much more complicated, and doesn't gain anything in the use cases I've met. Pete ******************************************************************** This email and any attachments are confidential to the intended recipient and may also be privileged. If you are not the intended recipient please delete it from your system and notify the sender. You should not copy it or use it for any purpose nor disclose or distribute its contents to any other person. ********************************************************************
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|