Representing XML Schema in OML

Reminder: Because MS-Word 2000 is being used to generate these web pages, it is highly recommended that you use Microsoft Internet Explorer version 5.0 when viewing this site.

Overview

We illustrate how to represent XML schemas in O by Norman Walsh concerned with purchase orders. Even with this simple example, we see the problem for a framework that intends to model both document structure and abstract object semantics. This is closely related to the data modeling problems of the RDF and XML Schema working groups, and also to the desire of Tim Berners-Lee in moving from web document models to the “Semantic Web”, expressed in his newest Web Architecture note, to merge the tree and labeled directed graph data models. In contrast, OML is explicitly oriented towards the representation of abstract semantics. Document structure comes out of this as a small by-product. Although XML Schema may regard the notion of a purchase order as a document type, OML would truly regard the purchase order notion as an abstract object type.

We can represent all features of XML Schema in OML. Unfortunately (for XML Schema) the converse is not the case – we cannot represent all OML features in the XML Schema language (although we can represent the unabbreviated form of OML in an XML schema). The most glaring omission in the XML Schema language is the lack of a general form of constraint representation, other than subtyping. In OML we have three general forms of constraints: the sequents from Information Flow logic, the expressions from the Calculus of Binary Relations, and the general assertions corresponding to Conceptual Graphs.

Feature Analogies

XML Schema

OML

elementType

Type.Object, Type.Function, Type.BinaryRelation

archetype

Type.Object

datatype

Type.Data

datatypeRef

tgtType

elementTypeRef

embedded function or binary relation

refinable archetype

subtype

schema composition

extends

validity

type correctness

minOccur

min-card

maxOccur

max-card

minOccur = maxOccur

card

Color Code

 

XML Schema

 

 

OML

 

Example: XML Schema

The notion of a purchase order is represented in the following XML schema.

 

<!DOCTYPE schema SYSTEM "o:/reference/w3c/schema/structures.dtd">

<schema>

 

<archetype name="address" model=“refinable”>

  <sequence>

    <elementTypeRef name="company" minOccur="0" maxOccur="1"/>

    <elementTypeRef name="name" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="street" minOccur="1" maxOccur="2"/>

    <elementTypeRef name="city" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="state" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="zip" minOccur="1" maxOccur="1"/>

  </sequence>

</archetype>

 

<elementType name="billing.address">

  <archetypeRef name="address"/>

</elementType>

 

<elementType name="shipping.address">

  <archetypeRef name="address"/>

</elementType>

 

<elementType name="items">

  <elementTypeRef name="item" minOccur="1"/>

</elementType>

 

<elementType name="item">

  <sequence>

    <elementTypeRef name="quantity" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="product.number" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="description" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="unitcost" minOccur="1" maxOccur="1"/>

  </sequence>

</elementType>

 

<elementType name="purchase.order">

  <sequence>

    <elementTypeRef name="date" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="billing.address" minOccur="1" maxOccur="1"/>

    <elementTypeRef name="shipping.address" minOccur="0" maxOccur="1"/>

    <elementTypeRef name="items" minOccur="1" maxOccur="1"/>

  </sequence>

</elementType>

 

<elementType name="company">

  <mixed/>

</elementType>

 

<elementType name="name">

  <mixed/>

</elementType>

 

<elementType name="street">

  <mixed/>

</elementType>

 

<elementType name="city">

  <mixed/>

</elementType>

 

<elementType name="state">

  <mixed/>

</elementType>

 

<datatype name="zipCode">

  <basetype name="string"/>

  <lexicalRepresentation>

    <lexical>99999</lexical>

    <lexical>99999-9999</lexical>

  </lexicalRepresentation>

</datatype>

 

<elementType name="zip">

  <datatypeRef name="zipCode"/>

</elementType>

 

<elementType name="product.number">

  <mixed/>

</elementType>

 

<elementType name="description">

  <mixed/>

</elementType>

 

<datatype name="quantityType">

  <basetype name="integer"/>

  <minExclusive>0</minExclusive>

</datatype>

 

<elementType name="quantity">

  <datatypeRef name="quantityType"/>

</elementType>

 

<datatype name="currency">

  <basetype name="decimal"/>

  <precision>8</precision>

  <scale>2</scale>

</datatype>

 

<elementType name="unitcost">

  <datatypeRef name="currency"/>

</elementType>

 

<elementType name="date">

  <datatypeRef name="dateTime"/>

</elementType>

 

</schema>

 

Example: OML Ontology

We model this purchase order schema as an ontology. We have the following object, data, function, binary relation and list types.

Object Types

Purchase Order

Address

Billing Address

Shipping Address

Item

Primitive Data Types

String

Integer

Decimal

DateTime

Defined Data Types

Quantity (Type)

Zip Code

Currency

Function Types

date : Purchase Order ® DateTime

billing.address : Purchase Order ® Billing Address

shipping.address : Purchase Order ® Shipping Address

items : Purchase Order ® Items

quantity : Item ® Quantity

product.number : Item ® String

description : Item ® String

unitcost : Item ® Currency

company : Address ® String

name : Address ® String

city : Address ® String

state : Address ® String

zip : Address ® Zip Code

Binary Relation Type

street : Address ® String

List Type

Items

Here is the OML ontology for purchase orders.

 
<OML>
  <Ontology name=“Purchase Order” version=“1.0”>
    <comment>A purchase order ontology</comment>
    <extends ontology=“http://www.oml.org/ontology/” prefix=“OML”/>
 
    <Type.Object name=“PurchaseOrder”>
      <Type.Function name=“date” tgtType=“DateTime” min-card=“1”/>
      <Type.Function name=“billing.address” tgtType=“Billing.Address”
        min-card=“1”/>
      <Type.Function name=“shipping.address” tgtType=“Shipping.Address”/>
      <Type.Function name=“items” tgtType=“Items” min-card=“1”/>
    </Type.Object>
 
    <Type.Object name=“Item”>
      <Type.Function name=“quantity” tgtType=“Quantity” min-card=“1”/>
      <Type.Function name=“product.number” tgtType=“String” min-card=“1”/>
      <Type.Function name=“description” tgtType=“String” min-card=“1”/>
      <Type.Function name=“unitcode” tgtType=“Currency” min-card=“1”/>
    </Type.Object>
 
    <Type.Object name=“Address”>
      <Type.Function name=“company” tgtType=“String”/>
      <Type.Function name=“name” tgtType=“String” min-card=“1”/>
      <Type.Function name=“street” tgtType=“String” min-card=“1”/>
      <Type.Function name=“city” tgtType=“String” min-card=“1”/>
      <Type.Function name=“state” tgtType=“String” min-card=“1”/>
      <Type.Function name=“zip” tgtType=“ZipCode min-card=“1”/>
      <subtype specific=“Billing.Address”/>
      <subtype specific=“Shipping.Address”/>
    </Type.Object>
 
    <Type.Data name=“Quantity” var= “q” genus= “Integer”>
      <geq src=“q” tgt=“0”>
    </Type.Data>
 
    <Type.Data name=“ZipCode” var= “z” genus= “String”>
      <lexical src=“z” tgt=“99999”>
      <lexical src=“z” tgt=“99999-9999”>
    </Type.Data>
 
    <Type.Data name=“Currency” var= “c” genus= “Decimal”>
      <precision src=“c” tgt=“8”>
      <scale src=“c” tgt=“2”>
    </Type.Data>
 
    <Type.List name=“Items” genus=“Item”/>
  </Ontology>
</OML>
 

In XML Schema function types and binary relation types are identified by the elementTypeRef tag and defined by the elementType tag. This separates and disconnects the function type from its source type. For example, the zip function has Address as its source type, but it could have other types also. There is an implicit sum typing here. Although we could represent this in OML, normally the source type is explicitly expressed. For example, the zip function type would be specified as follows.

 

<Type.Function name=“zip” srcType=“Address” tgtType=“ZipCode”/>

 

Example: XML Schema Instance

 
<!DOCTYPE purchase.order SYSTEM "po.dtd">
 
<purchase.order>
 
  <date>16 June 1967</date>
 
  <billing.address>
    <name>Namron H. Slaw</name>
    <street>256 Eight Bit Lane</street>
    <city>East Yahoo</city>
    <state>MA</state>
    <zip>12481-6326</zip>
  </billing.address>
 
  <items>
    <item>
      <quantity>3</quantity>
      <product.number>248</product.number>
      <description>Decorative Widget, Red, Large</description>
      <unitcost>19.95</unitcost>
    </item>
    <item>
      <quantity>1</quantity>
      <product.number>1632</product.number>
      <description>
        Packed electron storage container, AA, 4-pack
      </description>
      <unitcost>4.95</unitcost>
    </item>
  </items>
 
</purchase.order>
 

Example: OML Instance

 

<PurchaseOrder>

 
  <date>16 June 1967</date>
 
  <billing.address>
    <name>Namron H. Slaw</name>
    <street>256 Eight Bit Lane</street>
    <city>East Yahoo</city>
    <state>MA</state>
    <zip>12481-6326</zip>
  </billing.address>
 
  <items>
    <li><item>
      <quantity>3</quantity>
      <product.number>248</product.number>
      <description>Decorative Widget, Red, Large</description>
      <unitcost>19.95</unitcost>
    </item></li>
    <li><item>
      <quantity>1</quantity>
      <product.number>1632</product.number>
      <description>
        Packed electron storage container, AA, 4-pack
      </description>
      <unitcost>4.95</unitcost>
    </item></li>
  </items>
 

</PurchaseOrder>

 

The XML Schema instance and the OML instance are essentially the same. Again, the difference between XML Schema and OML occurs principally at the level of schemata and ontologies.

However, one very important distinction at the level of instances is centered on the notion of abbreviations. OML follows RDF somewhat in its notion of abbreviated markup. RDF uses three forms of abbreviation. OML ignores one of these as being non-primitive, and modifies the other two so that they conform to the fundamental classification projection diagram of the OML data model. We discuss the abbreviation issue elsewhere. We summarize the purchase order example by noting that the above OML instance is in abbreviated form. The longer un-abbreviated form allows OML to have a single generic ontology representable as an XML schema.

 

é

Please send questions, comments and suggestions about this page to: Robert E. Kent rekent@ontologos.org

Copyright © 1999 TOC (The Ontology Consortium). All rights reserved.