Newsletter sign-up
View all newsletters

Enterprise Java Newsletter
Stay up to date on the latest tutorials and Java community news posted on JavaWorld

Sponsored Links

Optimize with a SATA RAID Storage Solution
Range of capacities as low as $1250 per TB. Ideal if you currently rely on servers/disks/JBODs

Easily maintain RDF metadata models

Use scripts developed with the Jena RDF API to manage Resource Description Framework models

  • Print
  • Feedback

Similarly to how XML became the well-known standard adapted by many software vendors for data exchange, Resource Description Framework (RDF) is going in the same direction for describing and interchanging metadata. XML describes data using a document type definition (DTD) or an XML Schema Definition (XSD). RDF uses XML syntax and RDF Schema (RFDS) to describe the metadata as a data model.

This article explains how to use custom utilities developed with the Jena RDF API for managing RDF models stored in either a relational database or a file. Developed by HP Labs, the Jena framework is an open source implementation of RDF, RDFS, and OWL (Web Ontology Language) and includes a rule-based inference engine. It provides a Java API for creating and manipulating RDF models. In this article, I introduce SemanticRDFUtils.bat, a script developed with Jena that includes several tasks for maintaining Jena RDF metadata models stored in a relational database or a flat file. This article also explains how to use Prot�g� for creating semantic RDF files that include the schema (.rdfs) and the data file (.rdf).

Software installation

The following software must be installed before using SemanticRDFUtils.bat. Links to these tools are included in Resources.

  • J2SE 1.3 or a more recent version
  • Jena 2.0
  • Oracle 9.2.0.1.0
  • Apache Ant 1.5.4 or a more recent version
  • Prot�g� 2.1

A quick look at RDF and RDFS files

The following XML listings show the RDF and RDFS files for a sample alphabet cross reference model. They were created using the Prot�g� 2.1 GUI tool. The RDF file can be used as input while running the scripts and RDF query tool. The RDFS file is useful when you work with Prot�g� to add more data to the RDF file.

Listing 1. RDFTest1.rdf

                        <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE rdf:RDF [
   <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
   <!ENTITY rdfs 'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#'>
   <!ENTITY Maana 'http://www.vvasam.com/Maana#'>
]>
<rdf:RDF xmlns:rdf=""
   xmlns:Maana=""
   xmlns:rdfs="">
<Maana:ASCII rdf:about="RDFTest_Instance_0"
   Maana:Name="A"
   Maana:value="65"
   rdfs:label="A:65">
   <Maana:system rdf:resource="RDFTest_Instance_2"/>
</Maana:ASCII>
<Maana:System rdf:about="RDFTest_Instance_1"
   Maana:Name="lowercase"
   rdfs:label="lowercase"/>
<Maana:ASCII rdf:about="RDFTest_Instance_10000"
   Maana:Name="b"
   Maana:value="98"
   rdfs:label="b:98">
   <Maana:system rdf:resource="RDFTest_Instance_1"/>
</Maana:ASCII>
<Maana:ASCII rdf:about="RDFTest_Instance_10001"
   Maana:Name="B"
   Maana:value="66"
   rdfs:label="B:66">
   <Maana:system rdf:resource="RDFTest_Instance_2"/>
</Maana:ASCII>
<Maana:AscXRef rdf:about="RDFTest_Instance_10002"
   rdfs:label="b:98:B:66">
   <Maana:keyName rdf:resource="RDFTest_Instance_10000"/>
   <Maana:keyValue rdf:resource="RDFTest_Instance_10001"/>
</Maana:AscXRef>
<Maana:AscXRef rdf:about="RDFTest_Instance_10005"
   rdfs:label="a:97:A:65">
   <Maana:keyValue rdf:resource="RDFTest_Instance_0"/>
   <Maana:keyName rdf:resource="RDFTest_Instance_8"/>
</Maana:AscXRef>
<Maana:System rdf:about="RDFTest_Instance_2"
   Maana:Name="uppercase"
   rdfs:label="uppercase"/>
<Maana:ASCII rdf:about="RDFTest_Instance_8"
   Maana:Name="a"
   Maana:value="97"
   rdfs:label="a:97">
   <Maana:system rdf:resource="RDFTest_Instance_1"/>
</Maana:ASCII>
</rdf:RDF>
                   


Listing 2. RDFTest1.rdfs

                        <?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE rdf:RDF [
   <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
   <!ENTITY system 'http://protege.stanford.edu/system#'>
   <!ENTITY Maana 'http://www.vvasam.com/Maana#'>
   <!ENTITY rdfs 'http://www.w3.org/TR/1999/PR-rdf-schema-19990303#'>
]>
<rdf:RDF xmlns:rdf=""
   xmlns:system=""
   xmlns:rdfs=""
   xmlns:Maana="">
<rdf:Property rdf:about="maxCardinality"
   rdfs:label="system:maxCardinality"/>
<rdf:Property rdf:about="minCardinality"
   rdfs:label="system:minCardinality"/>
<rdf:Property rdf:about="range"
   rdfs:label="system:range"/>
<rdfs:Class rdf:about="ASCII"
   rdfs:label="ASCII">
   <rdfs:subClassOf rdf:resource="Resource"/>
</rdfs:Class>
<rdfs:Class rdf:about="AscXRef"
   rdfs:label="AscXRef">
   <rdfs:subClassOf rdf:resource="Resource"/>
</rdfs:Class>
<rdf:Property rdf:about="Name"
   rdfs:label="Name">
   <rdfs:domain rdf:resource="ASCII"/>
   <rdfs:domain rdf:resource="System"/>
   <rdfs:range rdf:resource="Literal"/>
</rdf:Property>
<rdf:Property rdf:about="RDFTest_Slot_10003"
   rdfs:label="RDFTest_Slot_10003">
   <rdfs:range rdf:resource="Literal"/>
</rdf:Property>
<rdfs:Class rdf:about="System"
   rdfs:label="System">
   <rdfs:subClassOf rdf:resource="Resource"/>
</rdfs:Class>
<rdf:Property rdf:about="keyName"
   rdfs:label="keyName">
   <rdfs:range rdf:resource="ASCII"/>
   <rdfs:domain rdf:resource="AscXRef"/>
</rdf:Property>
<rdf:Property rdf:about="keyValue"
   rdfs:label="keyValue">
   <rdfs:range rdf:resource="ASCII"/>
   <rdfs:domain rdf:resource="AscXRef"/>
</rdf:Property>
<rdf:Property rdf:about="system"
   rdfs:label="system">
   <rdfs:domain rdf:resource="ASCII"/>
   <rdfs:range rdf:resource="System"/>
</rdf:Property>
<rdf:Property rdf:about="value"
   rdfs:label="value">
   <rdfs:domain rdf:resource="ASCII"/>
   <rdfs:range rdf:resource="Literal"/>
</rdf:Property>
</rdf:RDF>
                   


Overview of Jena and Prot�g�

The following sections give a high-level overview of Jena and Prot�g�. You can get more detailed information on both products from the links in Resources. For this article's purposes, I expect you already have a good understanding of Jena and Prot�g�.

Jena RDF and RDQL

The RDF data model is a collection of statements, with each statement consisting of three parts: resource, property, and value. The resource can be anything that can be identified by a URI and it can have properties. Each property contains its own values. A property, value, and statement can be a resource and have their own properties and values.

Jena persists the RDF model in either a database or a file. RDQL is query language for querying the RDF model. RDF provides a graph with directed edges where the nodes can be either resources or literals. RDQL offers a way of specifying a graph pattern that is matched against the graph to yield a set of matches. Figure 1 shows the RDF graph representation of the files shown in Listings 1 and 2.

Figure 1. RDF graph representation for the sample RDF file. Click on thumbnail to view full-sized image.

An ellipse represents the resource, and a rectangle represents the literal. The resource (subject) is linked to another resource or literal (object or value) through an arc, or arrow, (predicate or property), which can be considered a triple and is called a statement.

  • Print
  • Feedback

Archived Discussions (Read only)
Subject
. Forum migration complete By AthenAdministrator
. Forum migration update By AthenAdministrator
. VZcgVCStKugDYkYZwww By asdkjhuewr32
. RiFnvFIGgIdDaFn By asdkjhuewr23
. fBGSbuKBTA By asdkjhuewr23
. YKIBGwaVMIn By asdkjhuewr23
. DPheDbqvYIEA By abramoviesi
. SqrKOUyygJOtF By abramoviesi
. GgzMnfYYzPPlcoPzpCS By abramoviesi
. jkHmJqtLxqoNf By mypicst
. CfnrKmCpWIRPGG By Memmorium
. YjAjrGIdKxMqCsT By zxevil175
. Easily maintain RDF metadata models By JavaWorld