RDF/RDFS 황성욱, 김현주

I. RDF / RDFS

1. 참고 문헌과 사이트들

(1) the original Resource Description Framework specifications, RDF Model and Syntax (1999 Recommendation) and RDF Schema (1999 Proposed Recommendation).

(2) RDF/XML Syntax Specification (Revised)

W3C Recommendation 10 February 2004

• http://www.w3.org/TR/2004/REC-rdf-syntax-grammar-20040210/

(3) RDF Vocabulary Description Language 1.0: RDF Schema

W3C Recommendation 10 February 2004

• http://www.w3.org/TR/2004/REC-rdf-schema-20040210/

(4) 번역본

• http://dewey.yonsei.ac.kr/courses/metadata/rdf/rdf_model_syntax_spec_kor.html

• http://dewey.yonsei.ac.kr/courses/metadata/rdf/rdf_schem_spec_kor.html

(5) 참고문헌

• Practical RDF, By Shelley Powers, O'Reilly, July 2003, 360 pages (eBook)

(6) W3 표준안 들에 대한 간단한고 명확한 학습방법들을 제공하는 사이트 (by Blueland)

• http://www.w3schools.com/

RDF/RDFS에 대한 이해를 돕기 위한 사이트

• http://www.w3schools.com/rdf/default.asp

II. RDF Tutorial

RDF Tutorial

	The Resource Description Framework (RDF) is a language for representing information about web resources, such as content description, title, author, copyright information, availability schedules, and more. Start learning RDF!

Table of Contents

1. Introduction to RDF

This chapter gives an introduction to RDF and explains what RDF is.

2. RDF Example

This chapter explains an RDF example.

3. RDF Elements

This chapter explains the most common RDF elements.

4. RDF Containers

This chapter explains the RDF container elements bag, sequence, and alternative.

5. RDF Schema

This chapter explains the RDF Schema extension to RDF.

6. RDF Dublin Core

This chapter explains the Dublin Core initiative.

7. RDF Reference

This chapter contains a complete RDF reference.

8. RDF / OWL

This chapter describes the OWL language built on top of RDF.

1. Introduction to RDF

RDF is a language for representing information about web resources.

(1) What You Should Already Know

Before you study RDF you should have a basic understanding of XML and XML Namespaces.

If you want to study these subjects first, please visit W3Schools' XML Tutorial.

(2) What is RDF?

RDF stands for Resource Description Framework

RDF is for describing resources on the web

RDF is designed to be read by computers

RDF is not designed for being displayed to people

RDF uses URIs to identify web resources

RDF uses property values to describe web resources

RDF uses the terms resources, properties, and values

RDF also uses the the terms subject, predicates and objects

RDF is written in XML (XML을 이용해 RDF를 구현함)

RDF is a web standard

(3) RDF is Designed to be Read by Computers

RDF was designed to provide a common way to describe information so it can be read (and understood) by computer applications.

RDF descriptions are not designed to be displayed on the web.

(4) Examples of Use

Describing properties for shopping items, like price and availability

Describing time schedules for web events

Describing information about web pages, like created and modified date, title, and author

Describing content and rating for web pictures

Describing content for search engines

Describing electronic libraries

(5) URIs to Identify, Properties to Describe

RDF uses a URI (Uniform Resource Identifier) to identify a web resource, and properties to describe the resource.

The following example describes the resource http://www.w3schools.com/default.asp:

The example is simplified. Namespaces are omitted.

In the example above, the URI "http://www.w3schools.com/default.asp" is used to identify a web page, the property "author" describes the author of the page, and the property value is "Jan Egil Refsnes". The property "created" tells when the page was created, and the property "modified" when it was last modified.

(6) RDF 데이터 모델-resources, properties, values

RDF terminology use the words resources, properties and values. (3-tuple(=triple)구조)

Semantic Web p.13

In the above example:

http://www.w3schools.com/default.asp is the resource

The element <author> is a property

The value "Jan Egil Refsnes" is a value

【 노드와 아크 그래프】

Resource

property

value

author

created

modified

http://www.w3schools.com/default.asp

Jan Egil Refsnes

November 1, 1999

February 1, 2004

(7) RDF 데이터 모델-Subjects, Predicates Objects

RDF terminology also use the words subjects, predicates and objects.

※ subjects(=resources), predicates(=properties) and objects(=values).

In the above example:

The resource http://www.w3schools.com/default.asp is the subject

The property "author" is the predicate

The value "Jan Egil Refsnes" is the object

(8) RDF is Written in XML

As you can see from the example above, an RDF document is written in XML. The XML language used by RDF is called RDF/XML.

By using XML, RDF information can easily be exchanged between different types of computers using different types of operating system and application languages.

	XML	RDF
모델	순서화한 트리지향모델	객체의 관계지향 모델
스키마	문법적 해석- XML문서의 구조를 모델링	의미해석 - 지식 즉 의미를 모델링

웹정보자원을 표현하는데 있어 XML이 구문적 계층에서 데이터의 구조를 정의하는 데 이용되고, RDF가 의미적 계층에서 지식표현을  위한 기능을 한다. 서로 상호보완적임

(9) RDF is a Web Standard

RDF became a W3C (World Wide Web Consortium) Recommendation in February 2004.

A W3C Recommendation is understood by the industry and the web community as a web standard. A W3C Recommendation is a stable specification developed by a W3C Working Group and reviewed by the W3C Membership.

2. RDF Example

(1) RDF Example

This is a few lines from a list of CD records:

Title	Artist	Country	Company	Price	Year
Empire Burlesque	Bob Dylan	USA	Columbia	10.90	1985
Hide your heart	Bonnie Tyler	UK	CBS Records	9.90	1988
...

This is a few lines of an XML file with a reference to an RDF description:

The first line in the XML file is the XML declaration, telling the version of XML.

The rdf:RDF element (starting with rfd:RDF and ending with /rdf:RDF) indicates that the content is RDF.

The xmlns:rdf namespace, specifies that tags with the rdf: prefix are from the namespace defined by "http://www.w3.org/1999/02/22-rdf-syntax-ns#".

The xmlns:cd namespace, specifies that tags with the cd: prefix are from the namespace defined by "http://www.recshop.fake/cd".

The rdf:Description element (starting with rdf:Description and ending with /rdf:Description) contains the description of a resource identified by the rdf:about attribute.

The cd:artist element describes a property of the resource, and so does cd:country, etc.

(2) Resources, Properties, Values

When you think of RDF, think the following sentence: "Resources have Properties with Values".

From the example above you can read:

The Resource: http://www.recshop.fake/cd/Hide your heart" has a Property called "artist" with the value "Bonnie Tyler"

The Resource: http://www.recshop.fake/cd/Hide your heart" has a Property called "price" with the value "9.90"

Or like humans would normally say: "The CD Hide your heart costs $9.90"

3. RDF Main Elements

This chapter describes the most important elements of RDF.

(1) The RDF Element <rdf:RDF>

The RDF element is the root of the RDF document. It defines the XML document to be an RDF document and contains a reference to the xmlns:rdf namespace:

The root element of an RDF document must always be the <rdf:RDF> element, and the root element must always have a reference to the RDF namespace:

http://www.w3.org/1999/02/22-rdf-syntax-ns#

(2) The Description Element <rdf:Description>

The Description element describes a resource.

The about attribute identifies the resource.

Property elements are used to describe the resource:

The property elements (artist, country, company, price, and year) are defined in the namespace xmln:cd.

This namespace is outside RDF (and not a part of RDF). RDF defines only the framework. Properties must be defined by someone else (company, organisation, person, etc).

(3) Properties as Attributes

Properties can also be expressed as attributes (instead of elements):

In the example above, the properties (artist, country, company, price, and year) are expressed as attributes instead of elements.(축약구문 ; abbreviated syntax)

resource의 property를 element로 표현하는 것을 연속구문(serialization syntax)라고, 연속구문이나 축약구문이나 RDF파서에 의한 해석은 두 구문에서 동일하다. 그러나 연속구문이 사람이 더 읽기 쉽다.

※ W3C RDF validator : SiRPAC(Simple RDF Parser and Compiler)

(4) Properties as Resources

Properties can also be expressed as resources:

In the example above, the property artist does not have a value, but a reference to a resource containing information about the artist.

4. RDF Container Elements

Bag, Sequence, and Alternative are containers for other elements.

(1) The Bag Element <rdf:Bag>

The Bag element contains an unordered list of value elements:

In the example above, the property element <cd:artist> contains a "bag" of artist values.

(2) The Seq Element <rdf:Seq>

The Seq element contains an ordered list of value elements:

In the example above, the property element <cd:artist> contains an ordered sequence of artist values.

(3) The Alt Element <rdf:Alt>

The Alt element contains a list of alternative values for an element:

In the example above, the property element <cd:format>, contains a list of alternative format values.

※ “문에 대한 문”의 과정 “구체화(reification)”

• RDF는 웹자원(resource)의 type으로 문(statement)을 사용할 수 있다.

예를 들어 “Ryan은  KRG가 웹사이트 http://www.turningweb.com/index의 작성자라고 말한      다.”에서 보면,

KRG가

웹사이트 http://www.turning.com/index의

작성자이다.

Ryan

said

◦ rdf:predicate : 모델화한 문의 원래의 특성을 식별하고 특성값은 원래의 문에서 특정한          특성을 표현한 자원이다.

◦ rdf:subject : 모델화한 문에 의해 기술되는 자원을 식별하여 특성값은 원래의 문에 작성         된 자원이다.

◦ rdf:object : 모델화한 문의 특성값을 식별하며 특성값은 원래의 문의 오브젝트이다.

◦ rdf:type : 새로운 자원의 type을 기술하며, 모든 구체화한 문은  RDF:Statement의 인스          턴스이다.

http://www.turningweb.com/

http://purl.org.de/element/Creator

Knowledge Presentation Group

Ryan

http://www.w3.org/1999/02/22-rdf-synax-ns#Statement

rdf:type

rdf:subject

rdf:predicate

rdf:object

said

※ 사람이 읽기 쉬운 중첩된 구문

http://www.turningweb.com

http://www.turningweb.com/ID1129

Ryan

Ryan@turningweb.com

creator

name

email

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-nsw#"

xmlns:dc="http://purl.org/dc/element/1.1/"

xmlns:tw="http://www.turningweb.com" >

<rdf:description rdf:about="http://www.turningweb.com">

<dc:creator>

<rdf:description rdf:about="http://www.turningweb.com/ID1129">

<tw:name> Ryan </tw:name>

<tw:email> Ryan@turningweb.com </tw:email>

</rdf:description>

</dc:creator>

</rdf:description>

</rdf:RDF>

5. RDF Schema

RDF Schema is an extension to RDF.

(1) RDF Schema and Application Classes

RDF describes resources with classes, properties, and values.

In addition, RDF also need a way to define application-specific classes and properties. Application-specific classes and properties must be defined using extensions to RDF

One such extension is RDF Schema.

(2) RDF Schema (RDFS)

RDF Schema does not provide actual application-specific classes and properties.

Instead RDF Schema provides the framework to describe application-specific classes and properties

Classes in RDF Schema is much like classes in object oriented programming languages. This allows resources to be defined as instances of classes, and subclasses of classes.

(3) RDFS Example

The following example demonstrates some of the RDFS facilities:

In the example above, the resources "horse" and "dog" is a subclass of the class "animal".

(4) Example Abbreviated

Since an RDFS class is an RDF resource we can abbreviate the example above by using rdfs:Class instead if rdf:Description, and drop the rdf:type information:

That's it!

6. RDF Dublin Core

The Dublin Core provides properties for describing network objects, suitable for use by network search engines.

(1) The Dublin Core

RDF is metadata (data about data). RDF is used to describe information resources.

The Dublin Core is a set of predefined properties for describing documents.

The first Dublin Core properties were defined at the Metadata Workshop in Dublin, Ohio in 1995 and is currently maintained by the Dublin Core Metadata Initiative.

Property	Definition
Contributor	An entity responsible for making contributions to the content of the resource
Coverage	The extent or scope of the content of the resource
Creator	An entity primarily responsible for making the content of the resource
Format	The physical or digital manifestation of the resource
Date	A date of an event in the lifecycle of the resource
Description	An account of the content of the resource
Identifier	An unambiguous reference to the resource within a given context
Language	A language of the intellectual content of the resource
Publisher	An entity responsible for making the resource available
Relation	A reference to a related resource
Rights	Information about rights held in and over the resource
Source	A Reference to a resource from which the present resource is derived
Subject	A topic of the content of the resource
Title	A name given to the resource
Type	The nature or genre of the content of the resource

A quick look at the table above indicates that RDF is ideal for representing Dublin Core information.

(2) RDFS Example

The following example demonstrates the use of Dublin Core in RDF:

7. RDF Reference

(1) The RDF and RDFS Namespaces

The RDF namespace (xmlns:rdf) used by RDF is:

http://www.w3.org/1999/02/22-rdf-syntax-ns#

The RDFS namespace (xmlns:rdfs )used by RDF is:

http://www.w3.org/2000/01/rdf-schema#

(2) The RDF Extension and Mime Type

The recommended extension for RDF files is *.rdf, but *.xml is often used to provide compatibility with older xml parsers.

The registered mime type should be application/rdf+xml

(3) RDFS / RDF Classes

Element	Class of	Subclass of
rdfs:Class	All classes
rdfs:Datatype	Data types	Class
rdfs:Resource	All resources	Class
rdfs:Container	Containers	Resource
rdfs:Literal	Literal values (text and numbers)	Resource
rdf:List	Lists	Resource
rdf:Property	Properties	Resource
rdf:Statement	Statements	Resource
rdf:Alt	Containers of alternatives	Container
rdf:Bag	Unordered containers	Container
rdf:Seq	Ordered containers	Container
rdfs:ContainerMembershipProperty	Container membership properties	Property
rdf:XMLLiteral	XML literal values	Literal

(4) RDFS / RDF Properties

Element	Domain	Range	Description
rdfs:domain	Property	Class	The domain of the resource
rdfs:range	Property	Class	The range of the resource
rdfs:subPropertyOf	Property	Property	The property is a sub property of a property
rdfs:subClassOf	Class	Class	The resource is a subclass of a class
rdfs:comment	Resource	Literal	The human readable description of the resource
rdfs:label	Resource	Literal	The human readable label (name) of the resource
rdfs:isDefinedBy	Resource	Resource	The definition of the resource
rdfs:seeAlso	Resource	Resource	The additional information about the resource
rdfs:member	Resource	Resource	The member of the resource
rdf:first	List	Resource
rdf:rest	List	List
rdf:subject	Statement	Resource	The subject of the resource in an RDF Statement
rdf:predicate	Statement	Resource	The predicate of the resource in an RDF Statement
rdf:object	Statement	Resource	The object of the resource in an RDF Statement
rdf:value	Resource	Resource	The property used for values
rdf:type	Resource	Class	The resource is an instance of a class

(5) RDF Attributes

Element	Domain	Range	Description
rdf:about			Defines the resource being described
rdf:Description			Container for the description of a resource
rdf:resource			Defines a resource to identify a property
rdf:datatype			Defines the data type of an element
rdf:ID			Defines the ID of an element
rdf:li			Defines a list
rdf:_n			Defines a node
rdf:nodeID			Defines the ID of an element node
rdf:parseType			Defines how an element should be parsed
rdf:RDF			The root of an RDF document
xml:base			Defines the XML base
xml:lang			Defines the language of the element content
rdf:aboutEach			(removed)
rdf:aboutEachPrefix			(removed)
rdf:bagID			(removed)

Elements described as (removed) are removed from the latest RDF standard.

8. Introduction to OWL

OWL is a language for processing web information.

(1) What You Should Already Know

Before you study OWL you should have a basic understanding of XML, XML Namespaces and RDF.

If you want to study these subjects first, please visit:

W3Schools' XML Tutorial and RDF Tutorial.

(2) What is OWL?

OWL stands for Web Ontology Language

OWL is built on top of RDF

OWL is for processing information on the web

OWL was designed to be interpreted by computers

OWL was not designed for being read by people

OWL is written in XML

OWL has three sublanguages

OWL is a web standard

(3) What is Ontology?

Ontology is about the exact description of things and their relationships.

For the web, ontology is about the exact description of web information and relationships between web information.

(4) Why OWL?

OWL is a part of the "Semantic Web Vision" - a future where:

Web information has exact meaning

Web information can be processed by computers

Computers can integrate information from the web

(5) OWL was Designed for Processing Information

OWL was designed to provide a common way to process the content of web information (instead of displaying it).

OWL was designed to be read by computer applications (instead of humans).

(6) OWL is Different from RDF

OWL and RDF are much of the same thing, but OWL is a stronger language with greater machine interpretability than RDF.

OWL comes with a larger vocabulary and stronger syntax than RDF.

(7) OWL Sublanguages

OWL has three sublanguages:

OWL Lite

OWL DL (includes OWL Lite)

OWL Full (includes OWL DL)

(8) OWL is Written in XML

By using XML, OWL information can easily be exchanged between different types of computers using different types of operating system and application languages.

(9) OWL Example (Airport)

OWL Resource: http://www.daml.org/2001/10/html/airport-ont

Class: Airport

Properties:

elevation

iataCode

icaoCode

latitude

location

longitude

name

Produced using dumpont2.java

<표> OWL Resource: http://www.daml.org/2001/10/html/airport-ont

<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:owl="http://www.w3.org/2002/07/owl#"

xml:base="http://www.daml.org/2001/10/html/airport-ont">

<owl:Ontology rdf:about="">

<owl:versionInfo>$Id: airport-ont.daml,v 1.1 2002/03/14 06:24:16 mdean Exp $</owl:versionInfo>

<rdfs:comment>Airport</rdfs:comment>

</owl:Ontology>

<rdfs:Class rdf:ID="Airport">

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#name"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#iataCode"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#icaoCode"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#location"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#latitude"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#longitude"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#elevation"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>

</owl:Restriction>

</rdfs:subClassOf>

</rdfs:Class>

<owl:DatatypeProperty rdf:ID="elevation"/>

<owl:DatatypeProperty rdf:ID="iataCode"/>

<owl:DatatypeProperty rdf:ID="icaoCode"/>

<owl:DatatypeProperty rdf:ID="latitude"/>

<owl:DatatypeProperty rdf:ID="location"/>

<owl:DatatypeProperty rdf:ID="longitude"/>

<owl:DatatypeProperty rdf:ID="name"/>

</rdf:RDF>

<표> Class : Airport

<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:owl="http://www.w3.org/2002/07/owl#" xml:base="http://www.daml.org/2001/10/html/airport-ont">

<owl:Ontology rdf:about="">

<owl:versionInfo>$Id: airport-ont.daml,v 1.1 2002/03/14 06:24:16 mdean Exp $</owl:versionInfo>

<rdfs:comment>Airport</rdfs:comment>

</owl:Ontology>

<rdfs:Class rdf:ID="Airport">

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#name"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#iataCode"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#icaoCode"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#location"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#latitude"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#longitude"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>

</owl:Restriction>

</rdfs:subClassOf>

<rdfs:subClassOf>

<owl:Restriction>

<owl:onProperty rdf:resource="#elevation"/>

<owl:allValuesFrom rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>

</owl:Restriction>

</rdfs:subClassOf>

</rdfs:Class>

<owl:DatatypeProperty rdf:ID="elevation"/>

<owl:DatatypeProperty rdf:ID="iataCode"/>

<owl:DatatypeProperty rdf:ID="icaoCode"/>

<owl:DatatypeProperty rdf:ID="latitude"/>

<owl:DatatypeProperty rdf:ID="location"/>

<owl:DatatypeProperty rdf:ID="longitude"/>

<owl:DatatypeProperty rdf:ID="name"/>

</rdf:RDF>

<표> dumpont2.java

dumpont is a program to display the class and property hierarchies present in an RDF Schema or DAML+OIL or OWL ontology. This implementation, based on Jena 2 replaces a previous implementation based on RDF API.

Following is Source Code <dumpont2.java>

// $Id: dumpont2.java,v 1.2 2003/11/07 14:46:31 mdean Exp $

/**

* print class and property hierarchies from an ontology.

*/

class dumpont2

{

static boolean html = true;

static String hyperdaml = "http://www.daml.org/cgi-bin/hyperdaml";

static boolean verbose = false;

static java.util.Stack stack = new java.util.Stack();

static java.util.Comparator comparator = new java.util.Comparator()

{

public int compare(Object o1, Object o2)

{

return o1.toString().compareTo(o2.toString());

}

public boolean equals(Object comparator)

{

return false;

}

};

/**

* information about a DAML Class

*/

static class Class

{

static java.util.TreeMap classes = new java.util.TreeMap(comparator);

com.hp.hpl.jena.rdf.arp.AResource node;

boolean restriction = false;

java.util.Vector subclasses = new java.util.Vector();

java.util.Vector superclasses = new java.util.Vector();

java.util.TreeSet properties = new java.util.TreeSet(comparator);

java.util.TreeSet instances = new java.util.TreeSet(comparator);

Class(com.hp.hpl.jena.rdf.arp.AResource node)

{

this.node = node;

classes.put(node, this);

}

void print(int depth)

{

if (restriction || node.isAnonymous())

return;

String classFragment = fragment(node);

if (html)

{

System.out.println("<li>");

System.out.println("<a name=" + quoted(classFragment) + ">");

}

else

for (int i = 0; i < depth; i++)

System.out.println("  ");

System.out.print("<a href=" + quoted(hyperdaml + "?" + node) + ">" + classFragment + "</a>");

// check for cycles

if (stack.contains(this))

{

System.out.println(" ... cycle ...");

return;

}

stack.push(this);

// properties

System.out.print(" (");

java.util.Iterator iterator = properties.iterator();

boolean first = true;

while (iterator.hasNext())

{

Object property = iterator.next();

if (! first)

System.out.print(", ");

first = false;

if (html)

{

String fragment = fragment(property);

System.out.print("<a href=" + quoted("#" + fragment) + ">" + fragment + "</a>");

}

else

System.out.print(property);

}

System.out.println(")");

// recurse

iterator = subclasses.iterator();

java.util.Iterator instanceIterator = instances.iterator();

if (iterator.hasNext()

|| instanceIterator.hasNext())

{

if (html)

System.out.println("<ul>");

while (iterator.hasNext())

{

Class child = (Class) iterator.next();

child.print(depth + 1);

}

while (instanceIterator.hasNext())

{

String instanceFragment = fragment(instanceIterator.next());

if (html)

{

System.out.println("<li>");

System.out.println("<a name=" + quoted(instanceFragment) + ">");

}

else

for (int i = 0; i < depth; i++)

System.out.println("  ");

System.out.println("instance " + instanceFragment);

}

if (html)

System.out.println("</ul>");

}

stack.pop();

}

static Class get(com.hp.hpl.jena.rdf.arp.AResource node)

{

Class retval = (Class) classes.get(node);

if (retval == null)

retval = new Class(node);

return retval;

}

}

/**

* information about a DAML Property

*/

static class Property

{

static java.util.TreeMap properties = new java.util.TreeMap(comparator);

com.hp.hpl.jena.rdf.arp.AResource node;

java.util.Vector subproperties = new java.util.Vector();

java.util.Vector superproperties = new java.util.Vector();

Property(com.hp.hpl.jena.rdf.arp.AResource node)

{

this.node = node;

properties.put(node, this);

}

void print(int depth)

{

String propertyFragment = fragment(node);

if (html)

{

System.out.println("<li>");

System.out.println("<a name=" + quoted(propertyFragment) + ">");

}

else

for (int i = 0; i < depth; i++)

System.out.println("  ");

System.out.print("<a href=" + quoted(hyperdaml + "?" + node) + ">" + propertyFragment + "</a>");

// check for cycles

if (stack.contains(this))

{

System.out.println(" ... cycle ...");

return;

}

stack.push(this);

System.out.println();

// recurse

java.util.Iterator iterator = subproperties.iterator();

if (iterator.hasNext())

{

if (html)

System.out.println("<ul>");

while (iterator.hasNext())

{

Property child = (Property) iterator.next();

child.print(depth + 1);

}

if (html)

System.out.println("</ul>");

}

stack.pop();

}

public String toString()

{

return node.getURI();

}

static Property get(com.hp.hpl.jena.rdf.arp.AResource node)

{

Property retval = (Property) properties.get(node);

if (retval == null)

retval = new Property(node);

return retval;

}

}

static String quoted(String string)

{

return '"' + string + '"';

}

static String fragment(Object object)

{

if (object == null)

return null;

String uri = object.toString();

int pound = uri.lastIndexOf('#');

return (pound == (-1)) ? uri : uri.substring(pound + 1);

}

static void printHeader(String header)

{

if (html)

System.out.print("<h2>");

System.out.print(header);

if (html)

System.out.print("</h2>");

System.out.println();

}

static void warn(String warning)

{

if (verbose)

System.err.println(warning);

}

static void usage()

{

System.err.println("Usage:  [-verbose] [-hyperdaml uri] <daml-uri>");

System.exit(1);

}

public static void main(String args[])

throws Exception

{

// parse arguments

String daml = null;

for (int i = 0; i < args.length; i++)

{

String arg = args[i];

if (arg.charAt(0) == '-')

{

if (arg.equals("-verbose"))

verbose = true;

else if (arg.equals("-hyperdaml"))

{

if ((i+1) > args.length)

usage();

hyperdaml = args[++i];

}

else

usage();

}

else

daml = arg;

}

if (daml == null)

usage();

// strip form input prefix

if (daml.startsWith("uri="))

daml = java.net.URLDecoder.decode(daml.substring(4));

// collect ontology information while streaming input

String rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";

String rdfs = "http://www.w3.org/2000/01/rdf-schema#";

final java.util.HashSet propertyTypes = new java.util.HashSet();

propertyTypes.add("Property");

propertyTypes.add("DatatypeProperty");

propertyTypes.add("ObjectProperty");

propertyTypes.add("TransitiveProperty");

propertyTypes.add("SymmetricProperty");

propertyTypes.add("UnambiguousProperty");

propertyTypes.add("UniqueProperty");

propertyTypes.add("FunctionalProperty");

propertyTypes.add("InverseFunctionalProperty");

propertyTypes.add("AnnotationProperty");

propertyTypes.add("OntologyProperty");

propertyTypes.add("DeprecatedProperty");

final java.util.HashSet otherTypes = new java.util.HashSet();

otherTypes.add("Ontology");

otherTypes.add("List");

otherTypes.add("DataRange");

com.hp.hpl.jena.rdf.arp.ARP arp = new com.hp.hpl.jena.rdf.arp.ARP();

arp.setStatementHandler(new com.hp.hpl.jena.rdf.arp.StatementHandler()

{

public void statement(com.hp.hpl.jena.rdf.arp.AResource subj,

com.hp.hpl.jena.rdf.arp.AResource pred,

com.hp.hpl.jena.rdf.arp.AResource obj)

{

String subject = subj.getURI();

String predicate = pred.getURI();

String object = obj.getURI();

String predicateFragment = fragment(predicate);

String objectFragment = fragment(object);

if (predicateFragment.equals("type")) // XXX - only rdf:type?

{

if (objectFragment.equals("Class"))

{

Class.get(subj);

}

else if (objectFragment.equals("Restriction"))

{

Class cl = Class.get(subj);

cl.restriction = true;

}

else if (propertyTypes.contains(objectFragment))

{

Property.get(subj);

}

else if (otherTypes.contains(objectFragment))

{

// nothing

}

else

{

Class cl = Class.get(obj);

cl.instances.add(subj);

}

}

else if (predicateFragment.equals("subClassOf"))

{

Class parent = Class.get(obj);

Class child = Class.get(subj);

parent.subclasses.add(child);

child.superclasses.add(parent);

}

else if (predicateFragment.equals("subPropertyOf"))

{

Property parent = Property.get(obj);

Property child = Property.get(subj);

parent.subproperties.add(child);

child.superproperties.add(parent);

}

else if (predicateFragment.equals("domain"))

{

Class cl = Class.get(obj);

Property property = Property.get(subj);

cl.properties.add(property);

}

else if (predicateFragment.equals("onProperty"))

{

Class cl = Class.get(subj);

cl.restriction = true;

Property property = Property.get(obj);

cl.properties.add(property);

}

}

public void statement(com.hp.hpl.jena.rdf.arp.AResource subj,

com.hp.hpl.jena.rdf.arp.AResource pred,

com.hp.hpl.jena.rdf.arp.ALiteral obj)

{

// nothing

}

});

java.io.InputStream stream = new java.net.URL(daml).openStream();

arp.load(stream, daml);

// sort

java.util.Collection sortedClasses = Class.classes.values();

java.util.Collection sortedProperties = Property.properties.values();

// propagate properties from Restrictions

java.util.Iterator iterator = sortedClasses.iterator();

while (iterator.hasNext())

{

Class cl = (Class) iterator.next();

if (cl.restriction)

{

java.util.Iterator subclasses = cl.subclasses.iterator();

while (subclasses.hasNext())

{

Class subclass = (Class) subclasses.next();

subclass.properties.addAll(cl.properties);

subclass.superclasses.remove(cl);

}

}

}

// print Classes

iterator = sortedClasses.iterator();

printHeader("Class Hierarchy");

if (html)

{

System.out.println("<ul>");

}

while (iterator.hasNext())

{

Class cl = (Class) iterator.next();

if (cl.superclasses.size() == 0) // root

cl.print(1);

}

if (html)

System.out.println("</ul>");

// print Properties

iterator = sortedProperties.iterator();

printHeader("Property Hierarchy");

if (html)

{

System.out.println("<ul>");

}

while (iterator.hasNext())

{

Property property = (Property) iterator.next();

if (property.superproperties.size() == 0) // root

property.print(1);

}

if (html)

System.out.println("</ul>");

// trailer

if (html)

{

System.out.println("<hr>");

System.out.println("<address>");

System.out.println("Produced from ");

System.out.println("<a href=" + quoted(daml) + ">" + daml + "</a> using <a href=" + quoted("http://www.daml.org/2003/09/dumpont/") + ">dumpont2</a>.java");

System.out.println("</address>");

}

}

(10) OWL is a Web Standard

OWL became a W3C (World Wide Web Consortium) Recommendation in February 2004.

A W3C Recommendation is understood by the industry and the web community as a web standard. A W3C Recommendation is a stable specification developed by a W3C Working Group and reviewed by the W3C Membership.