From: Ina C. <in...@st...> - 2001-01-25 04:22:53
|
Hi Tyson, Can you please take a look whether the schemas look ok or not? Thanks. Ina <in...@st...> ========================================================================== Mercury builtin types --------------------- Eg: int, float, char, string data: <stocknum>1</stocknum> schema: <element name="stocknum" type="mercury:int"/> <element name="comment" type="mercury:string"/> </element> Mercury enumeration ------------------- Eg: :- type fruit ---> apple ; orange ; banana ; pear. data: <fruit>apple</fruit> <fruit>banana</fruit> schema: <element name="fruit" type="tns:fruit"/> % (global declarations) <simpleType name="fruit" base="mercury:string"> <enumeration value="apple"/> <enumeration value="orange"/> <enumeration value="banana"/> <enumeration value="pear"/> </simpleType> or <element name="fruit" type="tns:fruit"/> <simpleType name="fruit"> <restriction base="mercury:string"> <enumeration value="apple"/> <enumeration value="orange"/> <enumeration value="banana"/> <enumeration value="pear"/> </restriction> </simpleType> Mercury structure ----------------- Eg: :- type book ---> book( title :: string, author :: author, intro :: string ). :- type author ---> author( surname :: string, firstname :: string ). data: <book> <title>Hello World</title> <author> <surname>Foo</surname> <firstname>Bar</firstname> </author> <intro>Introduction</intro> </book> schema: <element name="book" type="tns:book"/> <element name="author" base="tns:author"/> <complexType name="book"> <sequence> <element name="title" type="mercury:string"/> <element name="author" type="tns:author"/> <element name="intro" type="mercury:string"/> </sequence> </complexType> <complexType name="author"> <sequence> <element name"surname" type="mercury:string"/> <element name"firstname" type="mercury:string"/> </sequence> </complexType> Mercury union (members are simple types) ---------------------------------------- Eg. :- type myUnion ---> int ; float. data: <myUnion>1<myUnion> <myUnion>0.4<myUnion> schema: <simpleType name="myUnion"> % without 'type=' means <union memberTypes="int float"/> % anonymous type definitions </simpleType> Mercury union (members are complex types) ----------------------------------------- Eg: :- type book_info ---> author ; publisher. data: <book_info> <author> <surname>Foo</surname> <firstname>Bar</firstname> </author> </book_info> <book_info> <publisher> <name>Oxford</name> <date>120100</date> </publisher> </book_info> schema: <element name="book_info" type="tns:book_info"/> <element name="author" type="tns:author"/> <element name="publisher" type="tns:publisher"/> <complexType name="book_info"> <sequence> <choice> <element name="author" type="tns:author"/> <element name="publisher" type="tns:publisher"/> </choice> </sequence> </complexType> <complexType name="author"> <sequence> <element name"surname" type="mercury:string"/> <element name"firstname" type="mercury:string"/> </sequence> </complexType> <complexType name="publisher"> <sequence> <element name"name" type="mercury:string"/> <element name"date" type="mercury:int"/> </sequence> </complexType> Mercury list ------------ :- type list(T) ---> [] ; [T|list(T)]. schema: <element name="list" type="tns:list"/> <element name="nil" type="tns:nil"/> <element name="cons" type="tns:cons"/> <complexType name="list"> <sequence> <choice> <element name="nil" type="tns:nil"/> <element name="cons" type="tns:cons"/> </choice> </sequence> </complexType> <complexType name="nil> <complexContent> <restriction base="xsd:anyType"> </restriction> </complexContent> </complexType> or <complexType name="nil"> shorthand for complex content </complexType> that restricts anyType <complexType name="cons"> <sequence> <element name="head" type="xsd:anyType"> <element name="tail" type="tns:list"/> </sequence> </complexType> data: <list> <nil/> </list> <list> <cons> <head xsi:type="mercury:int">1</head> <tail> <list> <cons> <head xsi:type="mercury:int">2</head> <nil/> </cons> </list> </tail> </cons> <list> <nil/> Such an element has no content at all; its content model is empty -> define a type that allows only elements in its content, but we do not actually declare any elements and so the type's content model is empty. |