The Semantic Web In Part 2 of this series we reviewed Unicode, URI, and XML - three foundational technologies that permeate the existing Web and that are especially relevant to the emerging Semantic Web. We will put all three to use as we take our next step up the Semantic Web layer cake in a review of the Resource Description Framework (RDF). At the same time, we will be taking the visual RDF/OWL editor, Altova SemanticWorks, for a test drive. Since I will be using this tool for the very first time, you can expect an honest review that is rich with screenshots. If you do not already have the software, you may wish to download the trial version now so you can follow along.

RDF is a common framework for describing resources.

It is primarily intended to represent metadata that can be parsed and processed by machines rather than just displayed to people. While the resources it describes may be content or services that exist on the Web, they don't have to be; they can be real-world objects like you and I. Anything with identity can be described in RDF and, in this sense, RDF is a good candidate for recording and sharing knowledge on the Web.

With RDF, we can model information by describing concepts in a way that is consistent enough for machines to process uniformly. At the same time, we are able to describe any concepts that exist and in all the different ways that we prefer to conceptualize them. In RDF, we do this in much the same way we would when describing something to another person: we make statements about the thing.

In RDF, we make statements about things.

At its most basic level, RDF simply gives us a way to describe things in terms of properties and property values. Take the following natural language statement, for example:

"John Doe is a person."

John Doe has the property or characteristic of being a person. In RDF, the grammar of such a statement is much like the grammar of a sentence in the English language; it forms a recognized pattern:

<Subject><Predicate><Object>

John Doe
The thing the statement is about, so it is the subject.
is a
Identifies a property or characteristic of the subject, so it is the predicate.
person
The value of the property identified by the predicate, so it is the object.

A statement in RDF is called a triple.

Because statements in RDF are composed by a three-part grammar, they are also called 'triples'. Triples can be serialized in different ways. Contrary to popular belief, RDF/XML is not the only way to express a triple. Take the following RDF/XML statement for example:

  1. <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
  2. <rdf:Description rdf:about="http://www.semanticfocus.com/ont/Intro_Sem_Web">
  3. <dc:title>Semantic Web Introduction</dc:title>
  4. </rdf:Description>
  5. </rdf:RDF>

In Notation 3 (also known as just 'N3'), the same statement is expressed as follows:

  1. @prefix dc: <http://purl.org/dc/elements/1.1/>.
  2. <http://www.semanticfocus.com/ont/Intro_Sem_Web> dc:title "Semantic Web Introduction";

As you can see, N3 is a little less verbose. Another popular format is Turtle, the Terse RDF Triple Language. Both can be regarded as shorthand non-XML serializations of RDF models. Graphically, statements are often represented similar to the following:

Graphic Triple

As shown above, it is common to represent a subject or object as an oval. The property is represented as an arc connecting to the value. The value, in this case, is a character string. Property values that are character strings or other data types such as integers and dates are typically represented by a rectangular shape; these are also known as literal values or literals. As shown below, it is also possible for the value of an object to be another object. A property that connects to a resource, rather than a literal value can be called an object property.

Simple RDF Graph

RDF triples, create RDF graphs.

Now, graphically, we can begin to see how a collection of RDF statements creates an RDF graph. The model shown below gives us a sense of what RDF represents. This representation could be written in RDF/XML as a single document or in several that are linked together.

RDF Graph

RDF graphs create a 'web of data'.

Finally, when we link several resources together in RDF, we begin to achieve a web of data (or metadata, to be more precise). And that, my friends, is RDF in a nutshell. I've skipped a lot of detail that we may eventually cover, but for now, let us move on. Let's build something.

Hands-on RDF with Altova SemanticWorks

For the remainder of this article, I will be giving a tour of Altova SemanticWorks, a visual RDF/OWL editor for creating Semantic Web applications (list price: $129). For this evaluation, I am using a tutorial that you can also find in the tool's help system (shown below). I will shorten the tutorial to the bare essentials and attempt to use it as framework for introducing additional concepts.

Altova SemanticWorks RDF Tutorial

Following is the brief summary of our charter:

  1. Create a new RDF document
  2. Reference an ontology
  3. Make RDF statements

Create a new RDF document

Creating a new document in SemanticWorks is straight-forward as expected. After creating a new document (File/New or CTRL+N), you can change the document type by selecting it in the RDF/OWL Level combo box:

A new Altova SemanticWorks RDF document

Already this tool is providing valuable insight. As you can see from the RDF/OWL Level combo box, we are able to work with five different types of documents - each representing increasing levels of expressiveness.

RDF
An RDF file is where we put statements about resources. The RDF file is where we will define individual instances of the information objects defined in our model.
RDF Schema
An RDF Schema file is where we define the information model that all of our individual instances will be based on.

Additional document types are OWL Lite, OWL DL, and OWL Full - the three increasingly expressive flavors of the Web Ontology Language. The acronym should properly be WOL, but its inventors thought OWL just sounded better. I agree; WOL sounds like 'wall' (we don't need to be building any more of those in the Web). Today we will stick to plain ole RDF/RDFS and save OWL for extensive coverage in articles to come.

We can now toggle to the Text view of our new RDF file to see that the minimum source for an RDF file has been generated for us:

RDF text view

Reference an Ontology

Before we begin making RDF statements in this file, we need a model upon which the statements can be based. In Semantic Web terms, a model is typically called an ontology. An ontology is a formal specification of a conceptualization. It defines objects that exist in some domain (of knowledge), the properties they can have, and the relationships that exist among them. If you are used to content management concepts, you could think of an ontology as defining one or many content templates and the RDF as defining the instances created from those templates. Or, if you are accustomed to object oriented programming, you can think of the ontology as defining the classes and properties and the RDF as defining the instances.

An RDF file can reference one or more ontologies by importing their namespaces. We will import the following three by URI:

http://www.w3.org/2001/XMLSchema#
XML Schema namespace is a requisite base for the following imports
http://www.altova.com/ontologies/document#
Altova's document ontology - ready made for this tutorial
http://purl.org/dc/elements/1.1/
The Dublin Core Metadata element set - a useful set of common elements used to describe documents

After clicking Tools/Namespace Imports for RDF, we are presented with the following Namespace Imports dialog:

Namespace Imports Dialog

It is important to understand what is happening in the dialog above because it is common to many Semantic Web tools. At left, you are specifying a namespace URI, but since URIs do not necessarily resolve to an actual file, you must map the identifier to a file resource. If you have been following along since the beginning of this series, you may recall that URIs are identifiers; they are not necessarily locators. There is no guarantee that an actual file resource can be retrieved by pasting a URI in a browser, so sometimes we need to specify a mapping between the URIs and local file resources.

Now, I can tell you that I found Altova's tutorial to be quite sloppy on this point. The location of the sample RDF files given by the help documentation were only accurate for versions of Windows before Vista. Since I am using Vista, I had to hunt. Even worse, the location of the file for the XMLSchema document is neither documented nor even in the same location. A total newbie might get totally snagged on this point. After some searching, I was able to set up my mappings as follows (hopefully it will save you from the same hassle):

  • http://www.w3.org/2001/XMLSchema# | C:\Program Files\Altova\XMLSpy2008\Schemas\xmlspec\xml.xsd
  • http://www.altova.com/ontologies/document# | D:\<Users>\<User>\Documents\Altova\SemanticWorks2008\SemanticWorksExamples\Tutorial\AltovaDocuments.rdf
  • http://purl.org/dc/elements/1.1/ | D:\<Users>\<User>\Documents\Altova\SemanticWorks2008\SemanticWorksExamples\Tutorial\DCOntology.rdf

After importing documents and mapping the URIs to physical files, the next step is to declare namespaces for the RDF document. Basically, this means that for each namespace we've imported, we give an abbreviation. In this way, anything stated in the document can then just use the namespace prefix instead of the full URI. If we didn't have namespace prefixes, our RDF source code would have long URIs everywhere and would be atrocious. This step went for me without a hitch. You simply access the URIref Prefixes dialog (Tools | URIref Prefixes) and add a line for each required namespace and its prefix:

Namespace Prefixes

Somehow, during this process, my RDF document switched from RDF to OWL (in that combo box). After switching it back to RDF, I was able to see the resources available from the imported namespaces (shown below):

Resources now available

Now we can create an RDF resource based on the Altova Document model and some of the Dublin Core elements that we imported. Creating a new resource is as simple as clicking on the little icon under the Resources tab (as shown below):

Create resource

That creates a new element is the resources view where you can enter a name for the resource using a namespace prefix and a unique name for the new resource. For example: "doc:IntroToSemanticWeb".

Name the new resource

The next step is to define the predicates and objects of the new resource in the detail view. Right-click and select Add Predicate as shown below:

Add a predicate

You then select the property type. For example: "dc:language". Easy enough. To give a value for this property, you then right-click on it and select and select Add Resource Object:

Add value to property

Notice that your choices are resource, blank node, list, and literal. The language values have been modeled as objects in the doc namespace, so we can select one as the value of an object property to get the following:

Object property

Adding a literal property was just as easy. Instead of choosing a resource object, I selected Add literal object and then gave a string value for that literal:

Literal property

That is really all that is needed for a quick review of the tool. The final RDF/XML produced by the tool can then be viewed in the Text view as shown below:

Final text view

My First-use Review of Altova SemanticWorks?

If you are already familiar with Altova products like XMLSpy, then this could be a good tool for you. However, if you are new to RDF or Semantic Web concepts, you might think twice before cutting your teeth on this one. This is a visual RDF/OWL editor that gives the familiar XMLSpy visual metaphors and the powerful source view capabilities that Altova is known for. But don't expect to be hand-held; even the help files will not teach you much about Semantic Web concepts. This tool expects you to know what you are doing. I cut my own teeth on Protégé, a free, open-source ontology editor and knowledge-base framework. It is a great alternative that we will also explore in an upcoming article. The price of Altova SemanticWorks is not bad, however, so I will be trying it out more soon. Personally, I like to have a lot of toys in my tool-box; it seems that each does something better than the other and so I use a number of tools to get the benefits from each.

Conclusion

This article has provided a high-level overview of the Resource Description Framework and a quick summary of just one tool you can use to author RDF documents. In next week's article, we will begin to move into the next layer of the Semantic Web architecture with a discussion about Ontology and OWL. I will also show you how to create a nifty little Semantic Web application using Protégé. Until then, enjoy your work and enjoy the Web.

About the author

Cody Burleson

Cody Burleson is President and CEO of Burleson Technology Group, LLC. BTG provides Information Workplace and business integration solutions on leading enterprise platforms and is currently developing a semantic Workplace application. BTG also sponsors Workplace Design, a wiki community for sharing news, information, tools, and notes on the Information Workplace and business integration.

Trackback URL for this entry:

http://www.semanticfocus.com/blog/tr/id/82731/

Spam protection by Akismet

Comments for this entry:

No one has left a comment for this entry. Be the first!

Post a comment

  1. Spam protection by Akismet