![]() |
|
|
| Home | Resources | Buyer's Guide | FAQs | Newsletter | Tech Jobs | |
|
Introduction to DAML: Part I The Little Shop of KnowledgeLet 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"?>
<xsd:schema
targetNamespace="http://rdfinference.org/eg/supersports/dt"
xmlns:dt="http://rdfinference.org/eg/supersports/dt"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>
<!-- Pack capacity (in liters)-->
<xsd:simpleType name="packCapacity">
<xsd:restriction base="xsd:positiveInteger">
<xsd:maxExclusive value="50"/>
</xsd:restriction>
</xsd:simpleType>
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"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:daml="http://www.w3.org/2001/10/daml+oil#"
xmlns:dt="http://rdfinference.org/eg/supersports/dt"
xmlns:ss="http://rdfinference.org/eg/supersports/metadata"
xmlns:xsd="http://www.w3.org/2000/10/XMLSchema#"
xml:base="http://rdfinference.org/eg/supersports/metadata"
>
<daml:Ontology rdf:about="">
<daml:versionInfo>1.0</daml:versionInfo>
<rdfs:comment>An ontology of Super Sports Inc. store products
</rdfs:comment>
<daml:imports rdf:resource="http://www.w3.org/2001/10/daml+oil"/>
</daml:Ontology>
<daml:Class rdf:ID="Product">
<rdfs:label>Product</rdfs:label>
<rdfs:comment>An item sold by Super Sports Inc.</rdfs:comment>
</daml:Class>
<daml:Class rdf:ID="Department">
<rdfs:label>Department</rdfs:label>
<rdfs:comment>A Super Sports Inc. department</rdfs:comment>
</daml:Class>
<!-- *****************SIMPLE INHERITANCE***************** -->
<daml:Class rdf:ID="Tool">
<rdfs:label>Tool</rdfs:label>
<rdfs:comment>Tools used in sports,
ice axe for instance.</rdfs:comment>
<rdfs:subClassOf rdf:resource="#Product"/>
</daml:Class>
<daml:Class rdf:ID="Shoe">
<rdfs:label>Shoe</rdfs:label>
<rdfs:subClassOf rdf:resource="#Product"/>
</daml:Class>
<daml:Class rdf:ID="SleepingBag">
<rdfs:label>Sleeping Bag</rdfs:label>
<rdfs:subClassOf rdf:resource="#Product"/>
</daml:Class>
<daml:Class rdf:ID="BackPack">
<rdfs:label>Back Pack</rdfs:label>
<rdfs:subClassOf rdf:resource="#Product"/>
</daml:Class>
<!-- *****************ENUMERATION*****************-->
<daml:Class rdf:ID="Activity">
<rdfs:label>Activity</rdfs:label>
<rdfs:comment>A sport activity</rdfs:comment>
<daml:oneOf rdf:parseType="daml:collection">
<daml:Thing rdf:ID="Hiking">
<rdfs:label>Hiking</rdfs:label>
</daml:Thing>
<daml:Thing rdf:ID="Travel">
<rdfs:label>Travel</rdfs:label>
</daml:Thing>
<daml:Thing rdf:ID="Camping">
<rdfs:label>Camping</rdfs:label>
</daml:Thing>
<daml:Thing rdf:ID="Mountaineering">
<rdfs:label>Mountaineering</rdfs:label>
</daml:Thing>
</daml:oneOf>
</daml:Class>
<daml:Class rdf:ID="Availability">
<rdfs:label>Availability</rdfs:label>
<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>
<daml:Thing rdf:ID="BackOrdered">
<rdfs:label>Back ordered</rdfs:label>
</daml:Thing>
<daml:Thing rdf:ID="SpecialOrder">
<rdfs:label>Special order</rdfs:label>
</daml:Thing>
</daml:oneOf>
</daml:Class>
<!-- *****************DATATYPE PROPERTY*****************-->
<daml:DatatypeProperty rdf:ID="productNumber">
<rdfs:label>Product Number</rdfs:label>
<daml:samePropertyAs rdf:resource="<a
href="http://rosettanet.org/FundamentalBusiness">http://rosettanet.org/FundamentalBusiness</a>
DataEntities#ProprietaryProductIdentifier"/>
<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>
<daml:DatatypeProperty rdf:ID="packCapacity">
<rdfs:label>capacity</rdfs:label>
<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"/>
</daml:DatatypeProperty>
<!-- *****************OBJECT PROPERTY*****************-->
<daml:ObjectProperty rdf:ID="usedFor">
<rdfs:label>usedFor</rdfs:label>
<rdfs:comment>The activity for which a product is used</rdfs:comment>
<daml:domain rdf:resource="#Product"/>
<daml:range rdf:resource="#Activity"/>
</daml:ObjectProperty>
<!-- *****************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:productNumber>23456</ss:productNumber>
<ss:packCapacity>45</ss:packCapacity>
<ss:usedFor rdf:resource="#Hiking"/>
</ss:BackPack>
</rdf:RDF>
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 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 The 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,
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 comeIn 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. ReferencesDAMLHOME: 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)
|
|
| |
| Contact Us | Our Mission | Privacy Policy | Advertise With Us | Site Help | |
| Copyright © 2002 O'Reilly & Associates, Inc. | |