Lists Home |
Date Index |
I created a new XML schema language called
Water Contract and a new XML type language
called Water Type. These solutions could be used
to describe ConciseXML or XML documents.
Water Type and Water Contract documents can be
expressed in ConciseXML or XML syntax.
I've put some description below as well as links to
documents describing them.
A contract is an agreement that formalizes a set of expectations
or more parties. Water Contract takes the ideas behind a legal
contract and applies
them to software. Every Web service has an application programming
(API) for calling that service. In the past, a service's API was
described in a human-readable
text document. With Web services, the API is described in a text
as well as in a machine-readable form. DTD and XML Schema are two
formal languages for describing the structure of an XML document.
Water Contract is a formal language for fully describing a data
structure or API.
It uses the ConciseXML syntax and Water Contract and is both easier to
use than either DTD or XML Schema, as well as providing greater rigor
for describing an interface or data structure.
Most languages have
some way to constrain the fields of an object as well as the values of
field. Languages use different terms to describe the object that
constraints. For example, SQL has table definitions, Java has classes,
record definitions, C has structs, and XML has schema languages such
as W3C XML
schema or DTD's (Document Type Definitions). Water Contract uses
define constraints on data objects. A defclass represents a class, and
created from that class must obey the constraints defined in defclass
The following uses defclass to define a person class:
<defclass person name born_on/>
All instances of this class must supply values for the name and
born_on fields, so
both fields are required.
Here is an example of creating an instance of the person class:
<person name="Mike" born_on=<date 2002 10 10/> />
Required fields can be specified two ways:
1. By just listing the name and not supplying any value.
2. By explicitly putting required as the value of the field.
The following two lines are equivalent:
<defclass person name born_on/>
<defclass person name=required born_on=required/>
Optional fields can be specified two ways:
1. By giving a value to the field that is the field's default value.
2. By using optional as the value of the field.
The following two classes both have two optional fields:
<defclass person name="" status=="living "/>
<defclass person name=optional status=optional/>
The first line has an optional name field with a default value of the
empty string "".
The status field has a default value of "living ". The second line
uses optional for
both fields to say that the fields are not required.
Each field can also have an associated type.
The following example shows a person defclass with two fields: fname
born_on . fname has a required value and the value must be of type
born_on has an optional value, but if a value is given, it must be of
type date . Each
field follows the key=value=type form.
If no type is specified for a field, it can hold any object;
therefore, the default
type is thing .
A type is a description for categorizing value.
Water Type defines a set of core classes and types that represent
A type is an object which can be used to describe the possible values
in a field.
Water Type also defines the way in which new types can be created.
Water Type defines primitive classes and objects as several
non-primitive classes. The
three primitive objects are true, false, and null . The four classes
instances that are primitive objects are number, boolean, char, and
string . Primitive
objects form the base for constructing all other objects. Primitive
objects have a
_parent field and no other fields, while non-primitive objects can
have other fields.
In every other respect, primitive objects share the same properties as
Water Type defines several non-primitive objects including hypertext,
thing, date, time, datetime, datetime_interval, and duration.
Here are a few examples of defining new types:
<one_of "red " "green " "blue "/>
<one_of string hypertext/>
<set uppercase=type.<one_of <char "A "/> <char "B "/> <char "C "/>/>
<set uppercase_ABC=type.<vector_of uppercase min=2 max=15/>/>