ian,
having recently attempted the task of translating seamlessly between XML ->JSON->ruby hashes, i have a very low opinion of this sort of type declaration. it makes moving between representations a bear and most commonly results in eliminating the unit-specifier and normalizing to a known base (see option 4 below).
a 3rd option you did not mention is something like this:
<memory>
<size>2</size>
<units>GB</size>
</memory>
a 4th option, which i rather prefer since the units stuff tends to be relevant to and consumed by humans via UI rather than machines via API, is not to use units at all.
<memory>2147483648</memory>
either of the above is far easier to transform to and from non-XML representations, in my experience, with the latter being zero effort. a couple extra bytes won't harm us and we adhere to my first engineering rule: the best solution to a problem is not to have it in the first place.
b
I finished my PhD thesis on a RESTful model for grid computing a few years ago. I did some work on formalizing XML-based descriptors, including units/scaling. You may find that some of the material in Appendix B and C is useful:
http://crystal.harvard.edu/~ijstokes/thesis/RESTfulGrid-StokesRees-Thesis.pdf
I envisioned two options: i) units were specified in attributes on an element:
<memory type="GB"> 2 </memory>
ii) units were specified in-line and needed to be parsed:
<memory> 2 GB </memory>
At the time I felt that "type" provided a more generic modifier on a value than "units", and would allow things like:
<start type="USDate">5/21/2009</start>
or
<start type="EUDate">21/5/2009</start>
I provide 5 sets of "type" modifiers: time, frequency, metric, binary, transfer. No rocket science, but perhaps providing an cut-down portion of the schemas will be helpful, so I include them below.
Ian
<xs:simpleType name="TimeTypeList">
<xs:enumeration value="fs"/>
<xs:enumeration value="ps"/>
<xs:enumeration value="ns"/>
<xs:enumeration value="us"/>
<xs:enumeration value="ms"/>
<xs:enumeration value="s"/>
<xs:enumeration value="sec"/>
<xs:enumeration value="second"/>
<xs:enumeration value="min"/>
<xs:enumeration value="minute"/>
<xs:enumeration value="h"/>
<xs:enumeration value="hr"/>
<xs:enumeration value="hour"/>
<xs:enumeration value="d"/>
<xs:enumeration value="day"/>
<xs:enumeration value="wk"/>
<xs:enumeration value="week"/>
<xs:enumeration value="mon"/>
<xs:enumeration value="month"/>
<xs:enumeration value="yr"/>
<xs:enumeration value="year"/>
<xs:simpleType name="MetricTypeList">
<xs:enumeration value="f"/>
<xs:enumeration value="p"/>
<xs:enumeration value="n"/>
<xs:enumeration value="u"/>
<xs:enumeration value="m"/>
<xs:enumeration value="K"/>
<xs:enumeration value="M"/>
<xs:enumeration value="G"/>
<xs:enumeration value="T"/>
<xs:enumeration value="P"/>
<xs:simpleType name="FrequencyTypeList">
<xs:enumeration value="Hz"/>
<xs:enumeration value="KHz"/>
<xs:enumeration value="MHz"/>
<xs:enumeration value="GHz"/>
<xs:enumeration value="THz"/>
<xs:simpleType name="BinaryTypeList">
<xs:enumeration value="B"/>
<xs:enumeration value="KB"/>
<xs:enumeration value="MB"/>
<xs:enumeration value="GB"/>
<xs:enumeration value="TB"/>
<xs:enumeration value="PB"/>
<xs:simpleType name="TransferTypeList">
<xs:enumeration value="Kb/s"/>
<xs:enumeration value="Mb/s"/>
<xs:enumeration value="Gb/s"/>
<xs:enumeration value="Tb/s"/>
<xs:enumeration value="Pb/s"/>
_______________________________________________
occi-wg mailing list
occi-wg@ogf.org
http://www.ogf.org/mailman/listinfo/occi-wg