Basic units in XML (Was: Re: [QUANTITY] Units)

Brian Thomas thomas at mail630.gsfc.nasa.gov
Wed May 21 12:26:23 PDT 2003


On Wednesday 21 May 2003 02:03 pm, Jonathan McDowell wrote:
> While in Cambridge I wrote up some simplistic thoughts on
> how to model units, which I'm going to throw in as yet another
> take on one small aspect on the quantity thing.
> I have a short document at
>  http://hea-www.harvard.edu/~jcm/vo/units/units.ps
> or units.pdf, and a C implementation units.tar in the same
> directory.

	Jonathan, all,

        First of all "Hi", I don't expect many of you know me, so a concise introduction:
        I've been participating on NVO work for the past few years here at Goddard, in
        particular data modeling and query mechanisms, but have largely  be the 
        "silent" partner alongside of Kirk Borne and Ed Shaya who present the public
        face for us.

        Now, I took a quick look at your proposal. The decomposition of
        units into a basic set is also a thought that we had some time back.
        For our purposes in XDF, we found that you really only need about
        8 or 9 basic units from which all others may be built.

        Ed put together a nice little work on how to do this with XML using
        entities. The link is:

        http://xml.gsfc.nasa.gov/XDF/units.dtd

        (note: most browsers will screw this up, I suggest using "view source" or
         saving to a text file so you can see it) 

        For those who cant scan the DTD, I'll summarize it here:

        The basic "units" we found we needed were (and I'm doing this off-the-cuff, 
        so no heckling please):

        length = "meter"
        mass   = "gram"
        time     = "second"
        arc       = "radian"
        temp    = "kelvin"
        charge = "ampere"
        illumination   = "candella"
        number   = "number"

        and had the following basic functions, all "glued" together using MathML,
 which are similar in line with your paper:

 power
 plus 
 minus
 times 
 divide 
 log (w/ base)
 exp
 mag 


        IMO, the last one is not particularly "basic" and is really a "derived" function. So
        I could see a need to be able to create short-hand for functions, as well as units too.
        And, you also need some irregular numbers which are constants, such as "pi", as
        well as various physical constants, but we didn't think about this too much. 
        I expect a read through any version of Zombeck will take care of most of that.

        Having some basic units (whether in cgs, mks, or, *shudder* "english",
        or other) seems like the correct approach to me. 
        How to *parse* the equations (and how to represent them) which create
        the derived units is another matter (also addressed by your paper and
        others), and probably will be the subject of much debate I expect. 

        As an example with XML, and using entities, you can do nice things like define a derived unit
        with its English name so that it appears very readable to the user, e.g.

        <unit>&newton;</unit>

        whereas the DTD holds the entity definition:
<!ENTITY newton
'<units name="N">
        <apply><times/>
                <meter/>
                <kilogram/>
                <apply><power/>
                        <second/>
                        <cn>-2</cn>
                </apply>
        </apply>
</units>' >

        which is largely using MathML to encapsulate the equation for converting the basic
        units into the newton. The machine may thus read the value of "newton" and find
        exactly what the user meant by that English word in terms of a comparable set of
        basic units.

                                                -brian


>   - Jonathan



More information about the dm mailing list