It is not our task to consider in detail the syntax of OWL or SPARQL - for this we can use the specifications for these languages. Our task is to form a holistic understanding of the relationship between semantic technologies, and the implementation of semantic modeling ideas using currently existing software implementations. Therefore, we will consider the construction and use of semantic models using examples that include the implementation of models in several software environments at once.
First, you need to understand how the entities we described in the first section are represented in semantic models: individual objects, classes, definitions and property values. We'll start with the definition of a class. The fact of the existence of a class is stated by one triplet:
| Subject | Predicate | Addition |
|---|---|---|
| Unique class identifier | Has a type | Class |
In the following tables with triplets, we will not include the heading "subject - predicate - object" because the structure of the triplet is always the same.
By "Has a type" we denote a property defined in the RDF standard that is used to indicate the type of semantic model entities. The URI for this property looks like this: http://www.w3.org/1999/02/22-rdf-syntax-ns#type
We replaced the word "Class" with the URI of the "class" definition defined in the OWL standard. It looks like this: http://www.w3.org/2002/07/owl#Class
Note that if we stayed within the RDF/RDFS standard, the class definition would look like this: http://www.w3.org/2000/01/rdf-schema#Class. Thus, although OWL is in some ways an extension of the RDF standard, as can be seen from the URI above for the standard "has a type" property, it defines many entities differently.
We can come up with a unique class identifier ourselves. Let it be like this: http://example.ru/sample#OurFirstClass. Then our entire triplet will look like this:
| http://example.ru/sample#OurFirstClass | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://www.w3.org/2002/07/owl#Class |
The essence of this triplet, we repeat, is that http://example.ru/sample#OurFirstClass is a class. Note again that the following notation is just one way to express this information.
The above triplet is not very easy to understand. To make the entry more concise, it is customary to declare abbreviations for the “base” parts of the URI - so-called prefixes. At the beginning of the RDF file in XML syntax, prefixes can be declared like this:
<rdf:RDF xmlns="http://example.ru/sample#"
xml:base="http://example.ru/sample"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
As we see, for example, the abbreviation owl is declared for the expression http://www.w3.org/2002/07/owl#. After such a declaration, owl:Class will stand for http://www.w3.org/2002/07/owl#Class, and OurFirstClass will stand for http://example.ru/sample#OurFirstClass. The very first definition of xmlns=... defines a "empty" prefix that is substituted for all URIs that do not have an explicitly specified prefix and are not fully qualified. Taking into account these abbreviations, our triplet will be like this:
| OurFirstClass | rdf:type | owl:Class |
Let's see how to create this statement in the OWL editor. We will use Protégé, a freely available editor developed by Stanford University.
Having opened the editor, go to the Classes tab, click the Add Subclass button in the left list, and enter the name – OurFirstClass. Note that the editor made our class a subclass of the predefined class Thing, to which everything that exists belongs. However, this fact will not be reflected in any way in the files that we will receive after saving the model.

Creating a class in the Protégé editor
Let's save our model to see how it will look in the file. Please note that the editor offers us to choose from a set of formats, including RDF/XML and OWL/XML. If we select the first of them, the file will look like this (headers not shown):
If you select OWL/XML, the content of the file will look like this:
<Declaration>
<Class IRI="#OurFirstClass"/>
</Declaration>
Thus, the same model can be serialized in XML in completely different ways.
It is also interesting to observe what happens when the resulting files are imported into the triplet store through the SPARQL interface. To do this, we will use the Apache Jena product, or more precisely, the access point included in this SPARQL framework, called Fuseki. Fuseki, like other access points, has its own web interface for making requests, which can be used by both a person and a software product. Having entered this interface, click on the Control panel link and select a data set. After this, we will find ourselves on a page containing three forms corresponding to the main types of SPARQL queries:
- SPARQL Query – a request to retrieve information,
- SPARQL Update – a request to change information in the storage,
- File upload – upload an RDF/OWL file.
Let's first use the last form to download our file, exported from Protégé in RDF/XML format. Select the file and click the Upload button. As a result, Fuseki will show us the number of triplets created - there will be two of them.
Let's return to the previous page and run a simple SPARQL query that will return the entire contents of the model (we will discuss the syntax of SPARQL queries further):
SELECT * WHERE { ?a ?b ?c }
We will see that the result will be the same triplet that we cited above:
| http://example.ru/sample#OurFirstClass | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://www.w3.org/2002/07/owl#Class |
Let's now try to download the file in OWL/XML format. We will like the result much less: more than a dozen triplets will be created, the subject of which will be the so-called empty nodes, blank nodes - they do not have a constant name (URI), but are denoted by expressions like _:b0 (the same node can have different names in the results of different queries). These empty nodes correspond to XML elements in the source file that do not have their own identifiers (for example,
The first thing we want to do with classes is define subclasses. In Protégé, to do this, you need to place the cursor on the parent class and click the Add subclass button. In RDF/XML, the fact of the presence of a parent class will be reflected in this way:
<owl:Class rdf:about="http://example.ru/sample#SecondClass" /> <rdfs:subClassOf="http://example.ru/sample#OurFirstClass" /> </owl:Class>
When importing such a definition into the Triple store, two triplets are formed:
| http://example.ru/sample#SecondClass | http://www.w3.org/1999/02/22-rdf-syntax-ns#type | http://www.w3.org/2002/07/owl#Class |
| http://example.ru/sample#SecondClass | http://www.w3.org/2000/01/rdf-schema#subClassOf | http://example.ru/sample#OurFirstClass |
Referring to classes by their URI is not very convenient, even if you define a prefix. It should be taken into account that the URI, for example, cannot contain spaces, and a number of other special characters - which means that the entire “name” of the class must be one word. If we want users who are not familiar with semantic technologies to work with our classes, it is desirable to hide from them the fact that the unique identifier of a class is a URI. This requires the ability to give classes readable names, preferably in our native language.
In Protégé, the Annotations tab in the class properties is intended for this. By clicking on the “+” button located in it, we will see a dialog box for creating descriptions:

Description of the class in the Protégé editor
Listed on the left are several standard properties used to describe model elements. They are built-in definitions provided by the RDF/OWL standards. The most important of them is label - this property is precisely intended for specifying readable names of elements. Comment is also often used - a comment, an extended description of the element.
Having selected the label property, enter its value in the input field on the right side of the window. Please note that at the bottom there is also an opportunity to set the value type (in this case it will be a string) or language (Russian). It is not necessary to specify the value type, but it makes sense to select the language if you need to specify the element names in several languages. In XML/RDF our description will look like this:
<owl:Class rdf:about="http://example.ru/sample#SecondClass" /> <rdfs:label>Second class</rdfs:label> <rdfs:subClassOf="http://example.ru/sample#OurFirstClass" /> </owl:Class>
The triplet corresponding to the description looks like this:
| http://example.ru/sample#SecondClass | http://www.w3.org/2000/01/rdf-schema#label | "Second class" |
Names (labels) and other annotations are assigned in the same way to all the main elements of the semantic model - classes, individual objects and properties.
Next chapter: Simple ontological models: individual objects and properties