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"?>
<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
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.
References
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)
Got comments or questions on this article? Share them in our forum.
(* You must be a member of XML.com to use this feature.)
Comment on this Article
| Titles Only | Titles Only | Newest First |
- UniqueProperty
2002-10-29 09:42:47 Mohamed Keshk [Reply]
Hi,
I read your two articles, and they are really good. I got confused about Unique properties part when you mentioned:
"It permits a product to have more than one product number, as long as each is unique. "
but according to DAML+OIL (March 2001) Reference Description:
"Of course, this is a shorthand notation for the maxCardinality restriction of 1,"
Is there any conflict between the two statements?
Thanks.
Mohamed Keshk
- References
2002-02-11 10:43:18 Mike French [Reply]
The link for [DAMLOILNOTES-4] should be:
http://www.w3.org/TR/daml+oil-walkthru/
Mik
- Article updated
2002-02-06 09:57:46 Uche Ogbuji [Reply]
This article has been updated to address issues that have been raised by readers, and to include reference to the WEBONT W3C group, which is building on DAML+OIL
- Re: Disappointed
2002-02-03 07:57:30 Uche Ogbuji [Reply]
Thanks for your comments.
The second part does cover class expressions and such things that set DAML+OIL apart. I don't think it would have been appropriate to cover such things until one had covered the basic extensions DAML makes to RDFS.
The point of the unique property discussion was to show how one can constrain a property to be unique, not necessarily unique *and* unambiguous (i.e. your "identifying property" notion). I'm sorry you found the section confusing.
The article does not state that enumerations should not be extensible. The point was that with conventional approacheds to enums in RDF before DAML+OIL, update of enumerations could be added freely and out of sight, so to speak, of the schema.
The unused extended schema types is indeed a mistake. They are used in the longer example from the second article, and should have been removed from the listing in part 1.
DAML+OIL allows one to use the full machinery for user type definitions allowed in XSDL.
Yes. "usedFor" was inverted.
- Disappointed
2002-01-31 12:04:18 Evan Wallace [Reply]
I am a bit disappointed with this article. A reader of just this part could easily come away with the impression that DAML is just another web schema language that happens to be based on RDF[S]. As someone unfamiliar with DAML, I was hoping to see a discussion of those features that set it apart from languages for information modeling. Hopefully, the next two parts of this series of articles will focus on this.
There were a few other questions and comments that I had about Part I.
1) The discussion of Unique properties was confusing. This would have been better left to a time when the cardinality could have been constrained to one-to-one, so that productNumber could have been an identifying property for the class Product.
2) The issue of extensible enumerations has come up again and again in different contexts. I think many would disagree with the assertion that these are rarely desirable.
3) Where are the restricted types which were defined at the top of the second page, reused within the DAML below?
4) Can restricted type definitions such as these use compound constraints (something like a minExclusive value AND maxInclusive value constraint)?
5) Doesn't the definition of the ObjectProperty "usedFor" have its domain and range switched? Shouldn't it be a Product is usedFor an Activity?
Evan K. Wallace
Manufacturing Systems Integration Division
NIST
ewallace@nist.gov
