Since IMM uses Semantic Web technologies like RDF. OWL, and SPARQL, it is a requirement to first set up a useful and meaningful metadata model that can be expressed using the Web Ontology Language (OWL) as the first step in deploying an IMM solution.

The ontology is what defines and describes the data and relationships between everything that will be stored in the IMM Metadata Store.  Once you have your ontology defined you can use the IMM Visual Studio tools to generate .NET classes that can be used to populate data in the IMM Metadata Store and also build custom forms to collect metadata in a workflow.

Creating a new custom Ontology file

In order to create a new ontology for IMM, you must first have the IMM Core ontology and it's required imports available on your local machine. To do this, you can find all the core ontologies in the SDK folder of the IMM installation.  This is by default found at %Program Files (x86)%\Microsoft Interactive Media Manager 2008\SDK\Ontologies.

You should copy the following core OWL files into a new working directory.

  • IMM Core.owl
  • Dublin Core Elements.owl
  • Dublin Core Terms.owl
  • Dublin Core Types.owl

The reason you need the Dublin Core owl files, is that they are imported and used by the IMM Core Owl file.

Create a new directory in your working path. For this discussion lets say I created a new folder on my C drive called c:\Owl\Contoso.  Now I will copy the core Owl files into this new directory.  You should now have a folder that looks like this.

 image

Next create a new OWL file. In this case I will create a new blank file called Contoso.owl. I recommend that you use Altova Semanticworks to do this, since that is what I will be using for the rest of this article to explain how to edit an OWL ontology.

In SemanticWorks, select File->New, then save the file as Contoso.owl into your working directory - in my case c:\Owl\Contoso.

Defining your new Ontology and namespace

Next we will begin to define our new ontology.  In order to do this, we first need to set up a few things within SemanticWorks to make our lives easier.

Namespace imports are not automatic in SemanticWorks so we need to set then in Tools->Namespace Imports for RDF... menu.  Once in the menu, click Add to create a new row. In this row you need to add the following to the Namespace column

http://schemas.microsoft.com/imm/core/1.0#

In the Import File column, this should be the absolute path to your IMM Core.owl file. It should look similar to mine.

image

Now we need to make sure that all of the IMM Uri prefixes are set up in SemanticWorks so that it will collapse the Uris down to easy to read prefixes. To do this, go to the Tools->URIref Prefixes... menu.  In this dialog box you should see 3 prefixes already set up - owl, rdf and rdfs. We will now add the IMM required prefixes. An easy way to do this is to open up the IMM Core.owl file and view the URIref Prefixes that are already configured there.  Here are all the settings required:

Prefix URI
dc http://purl.org/dc/elements/1.1/
dcterms http://purl.org/dc/terms/
did urn:mpeg:mpeg21:2002:02-DIDMODEL-NS#
dii urn:mpeg:mpeg21:2002:01-DII-NS#
imm http://schemas.microsoft.com/imm/core/1.0#
owl http://www.w3.org/2002/07/owl#
rdf http://www.w3.org/1999/02/22-rdf-syntax-ns#
rdfs http://www.w3.org/2000/01/rdf-schema#
xsd http://www.w3.org/2001/XMLSchema#

Next you will need to define your own namespace for your custom ontology. This can be a URI that actually links to your OWL file on the Internet or just a reference urn if you like.  For my example ontology I have defined this namespace.

http://www.contoso.com/imm/1.0#

The namespace for your ontology must end in either a "#" or a "/" to be valid. 
You should also add a prefix to the URIref Prefixes for your own namespace to make it easier to edit the ontology. In this case I added a cont prefix for my namespace to the above list.

image

Now we will define the Ontology name, version, and import the IMM Core ontology. To do this, switch back to your custom ontology file in SemanticWorks and go to the "Ontologies" tab in the UI.

image

From here create a new owl:Ontology from the button in the Ontologies tab and name it exactly the same as your namespace. In my case http://www.contoso.com/imm/1.0#.

image

Importing the IMM Core Ontology

Select the button next to the namespace and right click on the new Ontology you defined. You will get a context menu with many options. From this menu select Add owl:imports.
Right click on the new owl:imports and select Add resource object.  In the new resource object, you will enter the URI for the IMM Core ontology.

Enter http://schemas.microsoft.com/imm/core/1.0#

It should now look like the following

image

Next right click on your Ontology name again and select Add owl:versionInfo  then right click on the versionInfo node and select Add literal.  Enter your desired version number here. In my case, I just used a simple "1.0" string.

Your completed Ontology definition and imports should look like this.

image
If you select from the menu RDF/OWL->Reload all imports  you should see both your ontology and the IMM Core ontology listed in the Ontologies tab now. This means that you have successfully imported the core ontology. If you look at the source code in the Text tab at the bottom of the page, you should see this very simple OWL definition. Save your ontology so far.

<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF xmlns:Prefix0="urn:newURI" xmlns:imm="http://schemas.microsoft.com/imm/core/1.0#" 
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#"> <rdf:Description rdf:about="http://www.contoso.com/imm/1.0#"> <rdf:type> <rdf:Description rdf:about="http://www.w3.org/2002/07/owl#Ontology"/> </rdf:type> <rdfs:comment>This is my comment about my sample ontology</rdfs:comment> <rdfs:label>Contoso Ontology</rdfs:label> <owl:imports> <rdf:Description rdf:about="http://schemas.microsoft.com/imm/core/1.0#"/> </owl:imports> <owl:versionInfo>1.0</owl:versionInfo> </rdf:Description> </rdf:RDF>

 

Defining Custom Properties

Now that we have a new Ontology definition, version number, and the IMM Core imported, we are ready to begin to define our new Properties and Classes and extend the IMM Core classes where necessary.

Go back to the RDF/OWL view by selecting the RDF/OWL button at the bottom of the page, exit out of your Ontology by clicking the Up button and then select the Properties tab. Here you should see a list of all the imported Dublin Core, IMM, and MPEG21 namespaces that are a part of the IMM Core ontology.

image

There are two types of properties that can be defined in OWL.  One is a DatatypeProperty, and the other is an ObjectProperty. It's easy to think about how these work -Datatype properties are used to store actual literal values such as strings, integers, booleans, decimal, etc.... ObjectProperties are used to point to other objects by URI.

To define a basic Datatype Property, select the owl:DatatypeProperty from the insert button in the Properties page.  You should see a new owl:DatatypeProperty with a urn:unnamed-1 title on it.

Edit the title to be the name of the property that you desire. In this case I will create a new property of type string called Artist. To do so, I use my previously defined prefix, a colon, and then the name Artist like this. 

cont:Artist

It is very important that you already added the URIref prefix to SemanticWorks as noted above, otherwise you will get an error later.  Switch to Text view and make certain that the full URI has been expanded in the rdf:about property for this new item. If it has not been expanded, than you probably entered the property before properly setting up your URIRef prefixes. If it says just cont:Artist, then you will get serious errors later.

    <rdf:Description rdf:about="http://www.contoso.com/imm/1.0#Artist">
       
<rdf:type>
           
<rdf:Description rdf:about="http://www.w3.org/2002/07/owl#DatatypeProperty"/>
       
</rdf:type>
   
</rdf:Description>

Next we will define the datatype of this property. Click into the property and you will be able to right click and Add Range.  The Range in OWL is what defines what is valid to be stored in this datatype property.

Right click the range node and select Add XML schema datatype, then select the schema type that you desire. In my case, I selected http://www.w3.org/2001/XMLSchema#string.
Your property will now look like the following.

image

Adding Properties to Classes

There are two ways in which to add a defined Property to a Class in Owl. One is Global, the other is local to the Class definition.  I prefer to use the later, due to the fact that when you define it on a Global level you lose some control later.

I'll start with the recommended route to add a Property to an existing IMM Core Class.

Let's use the example of adding our new Artist property to the IMM Core AudioItem definition.  Switch to the Classes tab in SemanticWorks and scroll down to the bottom past the Dublin Core imports to open up the the imm:AudioItem class definition.

Expand out the little plus sign (see red arrow below) at the top of the imm:AudioItem class. This will show you the imm:MediaItem node, which represents the fact that AudioItem derives from MediaItem. 

image

Right click on the arrow that I circled above in blue above and select Add Restriction.
In the drop down list select the property that you just created. This "restricts" the definition of AudioItem to now require a cont:Artist in my case.  At this point, we have not restricted the cardinality of the property, so it is in fact a collection of cont:Artist - meaning, I can have as many cont:Artist properties attached to an AudioItem as I want. If this is the desired outcome, you are done and the owl.exe tool will automatically generate a Collection of strings for the cont:Artist property.   If you want a single valued property you need to set the Max Cardinality.  To do this in SemanticWorks, there is a tiny (barely visible) ".."  under the property restriction.  Set the right side of this to "1" as below.

Your final property restriction should look like this.  You have now defined a single property on the AudioItem. Repeat the process of defining properties and adding them to the classes to build out your objects and vocabulary. 

image

In my next post I will go over how to define new classes in OWL.