Skip to main content

If you don't have an IBM ID and password, register here.

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. This profile includes the first name, last name, and display name you identified when you registered with developerWorks. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

The ultimate mashup -- Web services and the semantic Web, Part 3: Understand RDF and RDFs

Build and interpret Resource Description Framework (RDF) and RDF Schema Language (RDFs)

Nicholas Chase (ibmquestions@nicholaschase.com), Freelance writer, Backstop Media
Nicholas Chase has been involved in Web site development for companies such as Lucent Technologies, Sun Microsystems, Oracle, and the Tampa Bay Buccaneers. Nick has been a high school physics teacher, a low-level radioactive waste facility manager, an online science fiction magazine editor, a multimedia engineer, an Oracle instructor, and the Chief Technology Officer of an interactive communications company. He is the author of several books, including XML Primer Plus (Sams).

Summary:  The power of the ultimate mashup is the intelligence you'll build into it by using semantic Web techniques, specifically the Web Ontology Language (OWL). But before you can tackle OWL, you want to be familiar with its base language, the Resource Description Framework (RDF) and RDF Schema Language (RDFs). This tutorial gives you a good background in both RDF and RDFs so you'll be ready to build ontologies for your Web services, and also able to make use of RDF's power with other projects as well.

View more content in this series

Date:  08 Mar 2007 (Published 19 Sep 2006)
Level:  Intermediate PDF:  A4 and Letter (106 KB | 33 pages)Get Adobe® Reader®

Activity:  8339 views
Comments:  

A quick overview

Before you get too far along, let's discuss the mashup example application, the semantic Web, RDF and ontologies.

The story so far

A mashup is an application that takes data -- usually Web service data, and usually from more than one source -- and uses it to create something new. So far, in your quest to create the ultimate mashup, you created a system that displays information for an arbitrary number of Web services and displays it on a Web page.

The application is built to be as generic as possible. You can define the services in their own class, with an array of services to display. To add to or remove services from the final output, you can manipulate the contents of the array, and an XML template that specifies the ultimate display accompanies each service definition.

The end result is that you can control the services used, the appearance of their data on the final Web page, and even subservices linked to the main service by simply manipulating what amounts to input instructions.

The reason I made things so generic is partly to achieve flexibility and maintainability, and partly to prepare the application for what comes next.

And what comes next is a new way to find information.

The coming semantic Web

Right now, when you go to a search engine such as Google and enter a search term, it's hard to predict exactly what you're going to get back. If you enter the term SOAP, are you going to get back a selection of material on Web services, or advice on cleaning your laundry? Or an update on who killed the character Greg Madden on the television soap opera, "All My Children"?

Google does a lot of work finding out which category a particular Web page belongs to, by looking at what's linked to what, but in the long run, the string "SOAP" is just a string of letters, and discerning its meaning and context is a task currently best left to the human brain.

But things are different on the semantic Web. On the semantic Web, information is identified in a way that is understandable to machines, and allows software to accomplish this processing.

The example that is frequently used for this discussion involves travel arrangements or other appointments. On the semantic Web, an intelligent agent can check your schedule, find you a proper specialist with an appointment you can make, get ratings from current and former patients, and arrange for a babysitter to take care of your kids while you go.

All of this is possible only if the information published on the semantic Web is identified in a machine-readable -- and understandable -- way.

But here's the trick. The semantic Web isn't some new playground for which users must abandon the current Web. No, the semantic Web is just the current Web, but with more information.


Semantic Web services

If you label the Web services available to the mashup and their data in this way, with more information, you can enable the application to make intelligent choices. For example, the application is able to understand which services represent mapping information, and which represent online stores, or even further, online bookstores. It would know which information from those services represent the title, description, price, and so on.

That's the promise of semantic Web services; a system that understands what the underlying data represents, making it possible to use it in specific ways.

In this tutorial, it means your users can automatically swap out services of the same type -- using Barnes and Noble instead of Amazon, for example -- or even create new mashups of their own.

The structure in which you identify this information is called an ontology.


Ontologies

In their book, Website Indexing 2nd Edition, Glenda Browne and John Jermey define the word ontology this way:

"Ontology: specification of a conceptualisation of a knowledge domain. An ontology is a controlled vocabulary that describes objects and the relations between them in a formal way, and has a grammar for using the vocabulary terms to express something meaningful within a specified domain of interest. The vocabulary is used to make queries and assertions. Ontological commitments are agreements to use the vocabulary in a consistent way for knowledge sharing. Ontologies can include glossaries, taxonomies and thesauri, but normally have greater expressivity and stricter rules than these tools. A formal ontology is a controlled vocabulary expressed in an ontology representation language."

In other words, an ontology is an agreed-upon way to communicate specific ideas. So, if I wanted to make information about my blog available, I might publish something like this (see Listing 1):


Listing 1. Information encoded using the Dublin Core
                    
<rdf:RDF 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/">

   <rdf:Description rdf:about="http://www.chaosmagnet.com/blog">

      <b><dc:creator>Nicholas Chase</dc:creator>
      <dc:title>Chaos Magnet</dc:title>
      <dc:description>The personal and professional ramblings 
                         of technology author Nicholas Chase</dc:description> 
      <dc:date>2006-06-30</dc:date></b>

   </rdf:Description> 
</rdf:RDF>

This information is represented using terms from a structure called the Dublin Core. Whether or not you can call the Dublin Core an ontology is up for debate, but what is certain is that everyone agrees on the semantic meanings of creator, title, date, and so on.

In this case, you might create an ontology that specifies concepts such as:

  • Service
  • Map
  • Store
  • Bookstore
  • Price
  • Comment
  • Image
  • Thumbnail
  • Title

You can then specify individual services or data as "instances" of one or another of these concepts. To do that, you'll use the Web Ontology Language, or OWL.


Web Ontology Language (OWL)

Yes, yes, I know. The acronym for Web Ontology Language should be WOL, not OWL. But it's not, for reasons that range from references to Winnie the Pooh (and the wise Owl, who spelled his name W-O-L) to a tribute to early ontology projects such as Bill Martin's One World Language to the fact that it's just easier to say and to design logos for "OWL" than it is for "WOL".

All right, so now that is out of the way, what exactly is it?

Web Ontology Language, or OWL, provides a vocabulary for specifying information on the Web in such a way that machines can interpret it. Consider this example (see Listing 2):


Listing 2. A (very) simple ontology
                    
<rdf:RDF
    xmlns     ="http://www.example.com/mashup#"
    xml:base  ="http://www.example.com/mashup#"
    xmlns:owl ="http://www.w3.org/2002/07/owl#"
    xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"> 

<owl:Class rdf:ID="Store">
   <rdfs:label>Online Store</rdfs:label>
</owl:Class>

<owl:Class rdf:ID="Bookstore">
   <rdfs:subClassOf rdf:resource="#Store"/>
   <rdfs:label>Bookstore</rdfs:label>
</owl:Class>

<Bookstore rdf:ID="Amazon.com"/>
</rdf:RDF> 

The code in Listing 2 creates a main type of object, a Store, and a subclass of that type, the Bookstore. You can then use that new type to specify that Amazon.com is a Bookstore.

Not terribly exciting, until you consider that OWL also enables you to make various assertions about Bookstores, such as the fact that they're accessible online, they sell Books (which you can define as your own type), that they might also sell other specific types of things, and so on. By specifying Amazon.com as a Bookstore, all of that information automatically gets associated with it.

You'll learn all about OWL in Part 4 of this series, but before you get there, you need to address the form of the information, the Resource Description Framework.


Resource Description Framework (RDF)

The Resource Description Framework is an unambiguous way to state information about something. Many people consider it to be overly complicated, but when you come right down to it, RDF is just a way to specify the properties of resources. Going back to the blog example (see Listing 3):


Listing 3. Specifying properties of resources
                    
<rdf:RDF 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/">

   <rdf:Description rdf:about="http://www.chaosmagnet.com/blog">

      <dc:creator>Nicholas Chase</dc:creator>
      <dc:title>Chaos Magnet</dc:title>
      <dc:description>The personal and professional ramblings 
                        of technology author Nicholas Chase</dc:description> 
      <dc:date>2006-06-30</dc:date>

   </rdf:Description> 
</rdf:RDF>

In Listing 3, the code creates a Description that is about a resource, http://www.chaosmagnet.com/blog. The code specifies four properties, dc:creator, dc:title, dc:description, and dc:date, and the values of those properties. In this tutorial, I'll talk about graphs and triples and resources and all kinds of things that can make RDF seem overly complicated, but in the end, this is really all it is: assigning properties to resources in an agreed-upon way.


Resource description Framework Schema (RDFs)

As I said before, RDF is a way to assign properties to resources, and that's it. RDF itself doesn't even assign any meaning to those properties. Any meaning in a straight RDF document comes from the properties themselves, and not from the RDF. Unfortunately, that means that by itself, RDF isn't very useful for tasks such as defining vocabularies, in which you need a way to determine at least the basic relationships between concepts.

Enter RDF Schema. Part of the group of specifications thought of as "The RDF Recommendation", RDF Schema provides a way to create the basic relationships that define a vocabulary. Consider this example (see Listing 4):


Listing 4. A simple RDF Schema example
                    
<rdf:RDF
    xmlns     ="http://www.example.com/mashup#"
    xml:base  ="http://www.example.com/mashup#"
    xmlns:rdf ="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
 
<rdfs:Class rdf:ID="Service">
   <rdfs:label>Web Service</rdfs:label>
</rdfs:Class>

<rdfs:Class rdf:ID="Store">
   <rdfs:subClassOf rdf:resource="#Service"/>
   <rdfs:label>Online Store</rdfs:label>
</rdfs:Class>

<rdfs:Class rdf:ID="Bookstore">
   <rdfs:subClassOf rdf:resource="#Store"/>
   <rdfs:label>Bookstore</rdfs:label>
</rdfs:Class>

<rdf:Property  rdf:ID="endpoint">
   <rdfs:domain rdf:resource="#Service"/>
   <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#anyURI"/>
</rdf:Property>

<Bookstore rdf:ID="Amazon.com">
   <endpoint>
      http://soap.amazon.com/onca/soap?Service=AWSECommerceService
   </endpoint>
</Bookstore>
</rdf:RDF> 

In Listing 4, the code creates three Classes and a Property, endpoint. (I'll leave OWL out of the discussion until Part 4.) You can assign that property to any Service (which means it's applicable to Bookstore, as a subclass of Store, a subclass of Service) and it must have as a value an anyURI value as defined by the XML Schema recommendation.

RDF Schema provides these concepts as a set of basic building blocks you can use to build new languages and ontologies. In Part 4, we'll see how RDFs concepts go into making OWL, but first, in this tutorial, you'll find out how it works.

Let's start with RDF itself.

2 of 8 | Previous | Next

Comments



Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=XML, Information Management, Java technology, Open source, Web development, SOA and Web services
ArticleID=159864
TutorialTitle=The ultimate mashup -- Web services and the semantic Web, Part 3: Understand RDF and RDFs
publish-date=03082007
author1-email=ibmquestions@nicholaschase.com
author1-email-cc=dwxed@us.ibm.com

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Special offers