Representing XML Schema in IFF

Overview

We illustrate how to represent XML schemas in IFF with an example from a article 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 Web Architecture note, to merge the tree and labeled directed graph data models. In contrast, IFF 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, IFF would truly regard the purchase order notion as an abstract object type.

We can represent all features of XML Schema in IFF. Unfortunately (for XML Schema) the converse is not the case – we cannot represent all IFF features in the XML Schema language (although we can represent the unabbreviated form of IFF 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 IFF we have three general forms of constraints: the sequents from Information Flow, the expressions from the Calculus of Binary Relations, and the general assertions corresponding to Conceptual Graphs.

Feature Analogies

XML Schema

IFF

elementType

Object, Function, Relation

archetype

Object

datatype

Data

datatypeRef

entity

elementTypeRef

embedded function or relation

refinable archetype

subtype

schema composition

extends

validity

type correctness

minOccur

min-card

maxOccur

max-card

minOccur = maxOccur

card

Color Code

 

XML Schema

 

 

IFF

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 na name="unitcost">

  <datatypeRef name="currency"/>

</elementType>

 

<elementType name="date">

  <datatypeRef name="dateTime"/>

</elementType>

 

</schema>

Example: IFF Ontology

We model this purchase order schema as an ontology. We have the following object, data, function, 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

Relation Type

street : Address ® String

List Type

Items

Here is the IFF ontology for purchase orders.

<IFF>

  <Ontology name=“Purchase Order” version=“1.0”>

    <comment>A purchase order ontology</comment>

    <extends ontology=“http://www.ontologos.org/IFF/ontology/”/>

 

    <Object name=“PurchaseOrder”>

      <Function name=“date” target=“DateTime” min-card=“1”/>

      <Function name=“billing.address” target=“Billing.Address” min-card=“1”/>

      <Function name=“shipping.address” target=“Shipping.Address”/>

      <Function name=“items” target=“Items” min-card=“1”/>

    </Object>

 

    <Object name=“Item”>

      <Function name=“quantity” target=“Quantity” min-card=“1”/>

      <Function name=“product.number” target=“String” min-card=“1”/>

      <Function name=“description” target=“String” min-card=“1”/>

      <Function name=“unitcode” target=“Currency” min-card=“1”/>

    </Object>

 

    <Object name=“Address”>

      <Function name=“company” target=“String”/>

      <Function name=“name” target=“String” min-card=“1”/>

      <Function name=“street” target=“String” min-card=“1”/>

      <Function name=“city” target=“String” min-card=“1”/>

      <Function name=“state” target=“String” min-card=“1”/>

      <Function name=“zip” target=“ZipCode min-card=“1”/>

      <subtype specific=“Billing.Address”/>

      <subtype specific=“Shipping.Address”/>

    </Object>

 

    <Data name=“Quantity” var=“q” genus=“Integer”>

      <geq src=“q” tgt=“0”>

    </Data>

 

    <Data name=“ZipCode” var=“z” genus=“String”>

      <lexical src=“z” tgt=“99999”>

      <lexical src=“z” tgt=“99999-9999”>

    </Data>

 

    <Data name=“Currency” var=“c” genus=“Decimal”>

      <precision src=“c” tgt=“8”>

      <scale src=“c” tgt=“2”>

    </Data>

 

    <List name=“Items” genus=“Item”/>

  </Ontology>

</IFF>

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 IFF, normally the source type is explicitly expressed. For example, the zip function type would be specified as follows.

<Function name=“zip” source=“Address” target=“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: IFF 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 IFF instance are essentially the same. Again, the difference between XML Schema and IFF 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. IFF follows RDF somewhat in its notion of abbreviated markup. RDF uses three forms of abbreviation. IFF ignores one of these as being non-primitive, and modifies the other two so that they conform to the IFF knowledge/data model. See the discussion of IFF abbreviation syntax. We summarize the purchase order example by noting that the above IFF instance is in abbreviated form. The longer un-abbreviated form allows IFF 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 © 2000 TOC (The Ontology Consortium). All rights reserved. Revised: August 2000