[Tockit-general] Storing type definitions
Brought to you by:
jhereth,
peterbecker
From: Peter B. <pe...@pe...> - 2004-04-24 04:34:07
|
Hello all, after a long time I finally managed to have a look at the problem of storing types in structures such as many-valued contexts. As I've said on ICFCA in Sydney, I think reusing XML Schema, Part 2 [1] would be a good idea. Not only is that W3C endorsed (whatever that is good for ;-) ), but it is also used by other projects. And it is an existing specification for a whole range of basic types, how to extend them and how to store that in XML. At the moment I am working on moving the two types Siena supports into this schema. These types are a decimal type (with attributes such as minimum value, maximum value (both inclusive or exclusive) and the number of allowed fraction digits) and a textual type (string enumeration). These types are easy to map into XML Schema, the only little problem I had is that the names in XML Schema have to be so-called NCNames, which means only digits, basic latin characters and the underscore are allowed and digits only from the second character onwards. This problem can be avoided by attaching extra information into the annotation part of the type, using the <appinfo> element, which is meant for this purpose. Enough waffle, I think the examples should give a good idea how these types would look like, first the decimal one, the example type goes from 2 inclusive to 4 exclusive and allows two fraction digits. The internal name is "decimal1", the name used in the program is "A decimal type". "xs" is the standard XML Schema namespace: <xs:simpleType name="decimal1"> <xs:annotation> <xs:appinfo> <label>A decimal type</label> </xs:appinfo> </xs:annotation> <xs:restriction base="xs:decimal"> <xs:minInclusive value="2"/> <xs:maxExclusive value="4"/> <xs:fractionDigits value="2"/> </xs:restriction> </xs:simpleType> Note that the label doesn't have a namespace, which means it takes the default. We should probably put this stuff into some proper namespace, of course I'd use something like "http://www.tockit.org". I don't think we really need to create a subspace, but I am not sure about that yet. A string type allowing the values "one", "two" and "three" looks like this: <xs:simpleType name="textual1"> <xs:annotation> <xs:appinfo> <label>A textual type</label> </xs:appinfo> </xs:annotation> <xs:restriction base="xs:string"> <xs:enumeration value="one"/> <xs:enumeration value="two"/> <xs:enumeration value="three"/> </xs:restriction> </xs:simpleType> Apart from the slightly complicated way of getting the user-defined label into the system, I quite like the structures. And I think the specification of the basic types and how to extend them is nice and covers a lot of ground with the standard types. I think aiming to implement these alongside with UI elements for editing the type definitions, the values and predicates on the values would be a good way to progress in the many-valued context area. Peter [1] http://www.w3.org/TR/xmlschema-2/ |