Re: [Tockit-general] Storing type definitions
Brought to you by:
jhereth,
peterbecker
From: Peter B. <pe...@pe...> - 2004-04-24 04:51:29
|
PS: another option would be integrating the XML Schema definitions into other structures. The current Siena prototype uses this structure: <type class="net.sourceforge.toscanaj.model.manyvaluedcontext.types.NumericalType" name="Day" typeId="Day"> <range min="1.0" max="3.0" numberOfDecimals="0" /> </type> Here the inner bit is particular to the implementing class, which is instantiated dynamically from the "class" attribute using a constructor taking an JDOM Element with the information in it. The name in this case is the actual name used in the program, i.e. what was referred to as <label> before. The string example could thus look like this: <type class="org.tockit.xsd.SimpleDatatype" name="A textual type" typeID="textual1"> <xs:simpleType> <xs:restriction base="xs:string"> <xs:enumeration value="one"/> <xs:enumeration value="two"/> <xs:enumeration value="three"/> </xs:restriction> </xs:simpleType> </type> Advantages: - the XSD bit doesn't contain any foreign XML anymore, all extra bits are outside - other non-XSD types can be supported easily The class attribute could actually default to some XSD simple type implementation, thus making the XML more concise. Peter Peter Becker wrote: > 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/ > > > ------------------------------------------------------- > This SF.net email is sponsored by: The Robotic Monkeys at ThinkGeek > For a limited time only, get FREE Ground shipping on all orders of $35 > or more. Hurry up and shop folks, this offer expires April 30th! > http://www.thinkgeek.com/freeshipping/?cpg=12297 > _______________________________________________ > Tockit-general mailing list > Toc...@li... > https://lists.sourceforge.net/lists/listinfo/tockit-general > |