XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.


Introduction to DAML: Part I
Pages: 1, 2

The Little Shop of Knowledge

Let us look at an example illustrating the DAML features we have learned so far. We've acquired a trendy new online store for sports products, Super Sports. It's not enough to have cutting-edge merchandise, we also want to use the best technology for running the store, and so we shall come up with a DAML+OIL system for describing and classifying the products we sell.

The first step is to define a user-defined type that we wish to use in the product descriptions. The following listing is an XML schema definition for our data type.

<?xml version="1.0" encoding="UTF-8"?>

  <!-- Pack capacity (in liters)-->
  <xsd:simpleType name="packCapacity">
    <xsd:restriction base="xsd:positiveInteger">
      <xsd:maxExclusive value="50"/>

We define a back pack's capacity as an integer range from 1 to 50 using a restriction on the core positive integer type from XSDL.

You can see how we use this customized data type, and other constructs we've introduced, in the following DAML+OIL schema for the Super Sports product catalog.

<?xml version="1.0" encoding="UTF-8"?>


  <daml:Ontology rdf:about="">
    <rdfs:comment>An ontology of Super Sports Inc. store products
    <daml:imports rdf:resource="http://www.w3.org/2001/10/daml+oil"/>
  <daml:Class rdf:ID="Product">
    <rdfs:comment>An item sold by Super Sports Inc.</rdfs:comment>
  <daml:Class rdf:ID="Department">
    <rdfs:comment>A Super Sports Inc. department</rdfs:comment>
  <!-- *****************SIMPLE INHERITANCE***************** -->
  <daml:Class rdf:ID="Tool">
    <rdfs:comment>Tools used in sports, 
        ice axe for instance.</rdfs:comment>
    <rdfs:subClassOf rdf:resource="#Product"/>
  <daml:Class rdf:ID="Shoe">
    <rdfs:subClassOf rdf:resource="#Product"/>
  <daml:Class rdf:ID="SleepingBag">
    <rdfs:label>Sleeping Bag</rdfs:label>
    <rdfs:subClassOf rdf:resource="#Product"/>
  <daml:Class rdf:ID="BackPack">
    <rdfs:label>Back Pack</rdfs:label>
    <rdfs:subClassOf rdf:resource="#Product"/>
  <!-- *****************ENUMERATION*****************-->
  <daml:Class rdf:ID="Activity">
    <rdfs:comment>A sport activity</rdfs:comment>
    <daml:oneOf rdf:parseType="daml:collection">
      <daml:Thing rdf:ID="Hiking">
      <daml:Thing rdf:ID="Travel">
      <daml:Thing rdf:ID="Camping">
     <daml:Thing rdf:ID="Mountaineering">
  <daml:Class rdf:ID="Availability">
    <rdfs:comment>The availability of a product</rdfs:comment>
    <daml:oneOf parseType="daml:collection">
      <daml:Thing rdf:ID="InStock">
        <rdfs:label>In stock</rdfs:label>
      <daml:Thing rdf:ID="BackOrdered">
        <rdfs:label>Back ordered</rdfs:label>
      <daml:Thing rdf:ID="SpecialOrder">
        <rdfs:label>Special order</rdfs:label>
  <!-- *****************DATATYPE PROPERTY*****************-->
  <daml:DatatypeProperty rdf:ID="productNumber">
    <rdfs:label>Product Number</rdfs:label>
    <daml:samePropertyAs rdf:resource="<a
    <rdfs:domain rdf:resource="#Product"/>
    <rdfs:range rdf:resource="http://www.w3.org/2000/10/XMLSchema#nonNegativeInteger"/>
    <rdf:type rdf:resource="http://www.w3.org/2001/10/daml+oil#UniqueProperty"/>
  <daml:DatatypeProperty rdf:ID="packCapacity">
    <rdfs:comment>The capacity of a back pack</rdfs:comment>
    <rdfs:domain rdf:resource="#BackPack"/>
    <rdfs:range rdf:resource="http://rdfinference.org/eg/supersports/dt#packCapacity"/>
  <!-- *****************OBJECT PROPERTY*****************-->
  <daml:ObjectProperty rdf:ID="usedFor">
    <rdfs:comment>The activity for which a product is used</rdfs:comment>
    <daml:domain rdf:resource="#Product"/>
    <daml:range rdf:resource="#Activity"/>
  <!-- *****************INSTANCE***************** -->

  <ss:BackPack rdf:ID="ReadyRuck">
    <rdfs:label>Ready Ruck back pack</rdfs:label>
    <rdfs:comment>The ideal pack for your most rugged adventures</rdfs:comment>
    <ss:usedFor rdf:resource="#Hiking"/>

At the top level of the document is the RDF envelope element, as in most RDF/XML files. We define special namespaces to be used to construct URIs in our descriptions. Also note that we use an xml:base attribute [XMLBASE] to set the base URI of this document. This affects the actual URI to which RDF IDs are mapped in the model. For instance, given our declared base URI, rdf:ID="Product" yields a resource with URI http://rdfinference.org/eg/supersports/metadata#Product. This reduces the element of surprise when an RDF/XML document is retrieved from different URIs. The problem with this facility is that not all RDF or even XML processors support XML Base, which is a recent W3C Recommendation. We recommend for RDF usage in general that either XML Base is always used in documents with RDF IDs or that only rdf:about with fully resolved URIs is used.

Next up is the DAML+OIL header. This provides certain metadata for the ontology itself. In many cases, you should just be able to cut and paste our example header, changing the few fields as necessary. By having an empty rdf:about, we are treating the very document as the resource, using the XML Base we declared, of course. daml:versionInfo is an arbitrary value that describes versioning information for the document. It can be a simple string, as we have it here, or even a complex RDF or literal XML structure (such as revhistory from DocBook [DOCBOOK]).

The daml:imports allows you to incorporate another RDF model into the current one. This is similar to xsl:include in XSLT, not xsl:import because there is really no concept of import precedence for DAML+OIL. It is conventional to import the DAML+OIL specification itself, as we do, although the specifications are not clear on whether this is necessary (i.e whether such an import is implied).

Next we define a few simple classes, which should hold no surprises at this point. Then we define an enumeration of activities associated with Super Sports products and an enumeration of product availability codes. We next define some properties, using standard XSD data types, as well as the custom type we defined. One of these properties, productNumber, is a unique property: each product can only have one product number. Again, we define the product number as semantically equivalent to another property, the ProprietaryProductIdentifier from RosettaNet [ROSETTANET], an organization for standardization of business-to-business interchange. Note that this is just a made-up ID for the actual entry from the RosettaNet business dictionary.

And, finally, we define a single instance, as an example. It shows the use of a data-type property and an object property with an enumerated range.

More to come

In the next part of this series, we shall look at more complex DAML+OIL features, including restrictions, which are a fundamental provision of the language.


DAMLHOME: The DARPA Agent Markup Language (DAML) Program home page

DAMLOIL: DAML+OIL (March 2001)

DAMLOILNOTES-1, DAMLOILNOTES-2, DAMLOILNOTES-3, DAMLOILNOTES-4: A series of notes covering DAML+OIL as W3C technical reports

DOCBOOK: The home page of the DocBook Technical Committee

JJCONV: Five challenges for XML, a capsule of James Clark's keynote at the XML 2001 conference

OILHOME: The Ontology Inference Layer (OIL) home page

RDFHOME: Resource Description Framework (RDF): W3C Home Page

RDFINTRO: An Introduction to RDF, by Uche Ogbuji

RDFLG: Peter F. Patel-Schneider clarifies the common formula that RDF defines simple edge-labeled graphs

RDFSPEC: RDF Model and Syntax Specification, W3C Recommendation, 22 February 1999

RDFSSPEC: RDF Schema Specification 1.0 (W3C Candidate Recommendation, 27 March 2000)

RDFTUT: Pierre-Antoine Champin's RDF Tutorial

ROSETTANET: The RosettaNet home page

WEBONT: The W3C Web-Ontology (WebOnt) Working Group home page

XMLBASE: XML Base (W3C Recommendation, 27 June 2001)

1 to 5 of 5
  1. UniqueProperty
    2002-10-29 09:42:47 Mohamed Keshk
  2. References
    2002-02-11 10:43:18 Mike French
  3. Article updated
    2002-02-06 09:57:46 Uche Ogbuji
  4. Re: Disappointed
    2002-02-03 07:57:30 Uche Ogbuji
  5. Disappointed
    2002-01-31 12:04:18 Evan Wallace
1 to 5 of 5