(copy of a post on xml-dev)
Hi,
Thanks to all the comments and suggestions, I am pleased to announce a
new version of Examplotron implementing most of what I am now calling
the "iconic 80%" (a word derived from a post from John Cowan).
I am designing this new Examplotron as two tiers: the "iconic 80%" which
is based on the original idea that annotated instance documents can be
considered as highly intuive schemas and the "complemental 20%" which
will be introduced later on by "importing" the Relax NG patterns in the
Examplotron namespace.
This release is a first attempt to define an implement these iconic 80%
and I am surprised to see how far we can go and how easy the progression
is.
To illustrate this, we can borrow an Examplotron schema publish in W3C
XML Schema part 0 (yes, David C. Fallside had been writing Examplotron
schemas for a while, without even knowing...):
<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20">
<shipTo country="US">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<state>CA</state>
<zip>90952</zip>
</shipTo>
<billTo country="US">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Old Town</city>
<state>PA</state>
<zip>95819</zip>
</billTo>
<comment>Hurry, my lawn is going wild!</comment>
<items>
<item partNum="872-AA">
<productName>Lawnmower</productName>
<quantity>1</quantity>
<USPrice>148.95</USPrice>
<comment>Confirm this is electric</comment>
</item>
<item partNum="926-AA">
<productName>Baby Monitor</productName>
<quantity>1</quantity>
<USPrice>39.98</USPrice>
<shipDate>1999-05-21</shipDate>
</item>
</items>
</purchaseOrder>
Translated straight away into Relax NG, this schema is now giving:
namespace ega = "http://examplotron.org/annotations/"
namespace sch = "http://www.ascc.net/xml/schematron"
start =
element purchaseOrder {
attribute orderDate {
[ ega:example [ orderDate = "1999-10-20" ] ] xsd:date
}?,
element shipTo {
[ ega:example [ country = "US" ] ] attribute country { text }?,
element name { [ ega:example [ "Alice Smith" ] ] text },
element street { [ ega:example [ "123 Maple Street" ] ] text },
element city { [ ega:example [ "Mill Valley" ] ] text },
element state { [ ega:example [ "CA" ] ] text },
element zip { [ ega:example [ "90952" ] ] xsd:integer }
},
element billTo {
[ ega:example [ country = "US" ] ] attribute country { text }?,
element name { [ ega:example [ "Robert Smith" ] ] text },
element street { [ ega:example [ "8 Oak Avenue" ] ] text },
element city { [ ega:example [ "Old Town" ] ] text },
element state { [ ega:example [ "PA" ] ] text },
element zip { [ ega:example [ "95819" ] ] xsd:integer }
},
element comment {
[ ega:example [ "Hurry, my lawn is going wild!" ] ] text
},
element items {
# <item partNum="926-AA">
# <productName>Baby Monitor</productName>
# <quantity>1</quantity>
# <USPrice>39.98</USPrice>
# <shipDate>1999-05-21</shipDate>
# </item>
element item {
[ ega:example [ partNum = "872-AA" ] ]
attribute partNum { text }?,
element productName { [ ega:example [ "Lawnmower" ] ] text },
element quantity { [ ega:example [ "1" ] ] xsd:integer },
element USPrice { [ ega:example [ "148.95" ] ] xsd:decimal },
element comment {
[ ega:example [ "Confirm this is electric" ] ] text
}
}+
}
}
The new feartures since last version are that more inferences are done
by Examplotron (about the number of occurrences and about the datatypes
for instance). Also, the content of the schema is kept as Relax NG
annotations which can be pretty usefull for documentation and would
allow a round trip eg->rng->eg.
All these inferences can be overidden using Examplotron attributes and
flat schemas are also supported. If for instance, we want to define
complex types for the "purchaseOrder", "item", "billTo" and "shipTo"
elements (these last two have the same complex types), we would just
modify the schema to write:
<?xml version="1.0"?>
<purchaseOrder orderDate="1999-10-20" xmlns:eg="http://examplotron.org/0/" eg:define="po">
<shipTo country="US" eg:define="address">
<name>Alice Smith</name>
<street>123 Maple Street</street>
<city>Mill Valley</city>
<state>CA</state>
<zip>90952</zip>
</shipTo>
<billTo country="US" eg:content="address">
<name>Robert Smith</name>
<street>8 Oak Avenue</street>
<city>Old Town</city>
<state>PA</state>
<zip>95819</zip>
</billTo>
<comment>Hurry, my lawn is going wild!</comment>
<items>
<item partNum="872-AA" eg:define="item">
<productName>Lawnmower</productName>
<quantity>1</quantity>
<USPrice>148.95</USPrice>
<comment>Confirm this is electric</comment>
</item>
<item partNum="926-AA">
<productName>Baby Monitor</productName>
<quantity>1</quantity>
<USPrice>39.98</USPrice>
<shipDate>1999-05-21</shipDate>
</item>
</items>
</purchaseOrder>
And, converted into WXS through Trang, this would give:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="purchaseOrder" type="po"/>
<xs:complexType name="po">
<xs:sequence>
<xs:element ref="shipTo"/>
<xs:element ref="billTo"/>
<xs:element ref="comment"/>
<xs:element ref="items"/>
</xs:sequence>
<xs:attribute name="orderDate" type="xs:date"/>
</xs:complexType>
<xs:element name="shipTo" type="address"/>
<xs:element name="billTo" type="address"/>
<xs:element name="comment">
<xs:complexType mixed="true"/>
</xs:element>
<xs:element name="items">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" ref="item"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="item" type="item"/>
<xs:complexType name="address">
<xs:sequence>
<xs:element ref="name"/>
<xs:element ref="street"/>
<xs:element ref="city"/>
<xs:element ref="state"/>
<xs:element ref="zip"/>
</xs:sequence>
<xs:attribute name="country"/>
</xs:complexType>
<xs:element name="name">
<xs:complexType mixed="true"/>
</xs:element>
<xs:element name="street">
<xs:complexType mixed="true"/>
</xs:element>
<xs:element name="city">
<xs:complexType mixed="true"/>
</xs:element>
<xs:element name="state">
<xs:complexType mixed="true"/>
</xs:element>
<xs:element name="zip" type="xs:integer"/>
<xs:complexType name="item">
<xs:sequence>
<xs:element ref="productName"/>
<xs:element ref="quantity"/>
<xs:element ref="USPrice"/>
<xs:element ref="comment"/>
</xs:sequence>
<xs:attribute name="partNum"/>
</xs:complexType>
<xs:element name="productName">
<xs:complexType mixed="true"/>
</xs:element>
<xs:element name="quantity" type="xs:integer"/>
<xs:element name="USPrice" type="xs:decimal"/>
</xs:schema>
If you prefer the latest, please delete this mail.
Otherwise, your feedback is very welcome, either here or on the
Examplotron mailing list:
http://lists.xmlschemata.org/examplotron/
To subscribe, send a mail to examplotron-request@xmlschemata.org with
"subscribe" in the subject or body.
The next steps I have in mind are:
* more iconic 80% features including features to influence the
style of a schema (like: "generate all elements as global",
"generate all content as global", "allow foreign elements and
attributes wherever practical", ...)
* implementation of the 20% complemental
* implementation of the reverse transformation
Enjoy,
Eric
-- Lisez-moi sur XMLfr. http://xmlfr.org/index/person/eric+van+der+vlist/ ------------------------------------------------------------------------ Eric van der Vlist http://xmlfr.org http://dyomedea.com (W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema ------------------------------------------------------------------------Received on Mon Feb 3 17:24:08 2003
This archive was generated by hypermail 2.1.8 : Fri Dec 03 2004 - 14:29:47 UTC