1. RDF processing tools in Java
Corneliu Dicusar, Petru Rebeja
Web Application Development papers,
Faculty of Computer Science,
Iasi, Romania
{corneliu.dicusar, petru.rebeja}@info.uaic.ro
Abstract. This paper presents a comparison of several tools for RDF processing
in Java taking in account the following aspects: storage, SPARQL support,
support for developers and copyright.
Keywords: RDF, Java, RDFSchema, SPARQL, METAMorphoses, Jena, JRDF
1 Introduction
RDF1 became a key concept in knowledge interchange on the Web [1] nowadays and
one of the briks on which Semantic Web2 will be build. It allows software tools to
link data with their semantics rather than just acknowledge their existence without
further knowledge of means of data interpretation. Thus, RDF pushes the immense
collection of data stored today on the Web to a new, higher level towards Semantic
Web. Still, RDF in essence isn’t but just a framework for metadata. In order to use
this framework, developers need tools to do so. This paper presents a short
comparison of RDF processing tools in Java. The comparison will be made on how
RDF triples are stored, whether the specified tool provides SPARQL3 support, how
well it is documented for developers and it’s copyright. Each of these aspects will be
presented in a separated section of this document, all these sections being preceded by
a section containing a short description of each tool.
In order to comprise the notions of this document, the reader must be accustomed to
the following notions:
─ RDF
─ RDFS(chema)
─ SPARQL
─ Java
1 http://www.w3.org/RDF/
2
http://www.w3.org/2001/sw/
3 http://www.w3.org/TR/rdf-sparql-query/
2. 2 Corneliu Dicusar, Petru Rebeja
2 Java tools for RDF processing
Although there are a lot more tools for RDF processing in Java, this paper presents
only the three most popular of them. These are:
─ METAMorphoses4 developed by Martin Švihla5. It is a tool designed for
transforming data from a relational database into RDF documents, according to
mapping. It uses schema mappings and template documents written in XML
languages. It can be used as a common Java Library. This is not an actual RDF
handling tool, but we have chosen it, as an example of a very useful idea.
─ Jena6, from Hewlett-Packard, is a framework designed for building Semantic
Web applications. It offers the tools to handle RDF, RDFS, OWL, SPARQL,
and more, including a build in inference engine.
─ JRDF7, developed by Andrew Newman, a library that gives a simple user
interface following RDF standard for creation and management for RDF graphs.
3 Storing the triples
─ METAmorphoses transforms data stored in a relation database into RDF triples,
so it is natural that these triples appear in XML format. It takes the schema of
the database, and adapts it to an existing ontology. A great example is given by
the authors [2]. Having a simple database schema:
PERSON(#id, id_department,username, first_name,
family_name)
PROJECT(#id, web)
PERSON_PROJECT(person_id, project_id)
DEPARTMENT(#id, name)
And given the corresponding ontology:
<rdfs:Classrdf:ID="Person">
<rdfs:label>Person</rdfs:label>
</rdfs:Class>
<rdf:Propertyrdf:ID="surname">
<rdfs:rangerdf:resource="http://www.w3.org/2001/XMLSche
ma#
string"/>
<rdfs:domainrdf:resource="#Person"/>
</rdf:Property>
<rdf:Propertyrdf:ID="hasDepartment">
4
http://metamorphoses.sourceforge.net/
5 http://www.svihla.net/
6
http://jena.sourceforge.net/
7 http://jrdf.sourceforge.net/
3. RDF processing tools in Java 3
<rdfs:rangerdf:resource="http://www.w3.org/2001/XMLSche
ma#
string"/>
<rdfs:domainrdf:resource="#Person"/>
</rdf:Property>
<rdf:Propertyrdf:ID="currentProject">
<rdfs:rangerdf:resource="#Project"/>
<rdfs:domainrdf:resource="#Person"/>
</rdf:Property>
<rdfs:Classrdf:ID="Project">
<rdfs:label>Project</rdfs:label>
</rdfs:Class>
<rdf:Propertyrdf:ID="participants">
<rdfs:domainrdf:resource="#Project"/>
<rdfs:rangerdf:resource="#Person"/>
</rdf:Property>
<rdf:Propertyrdf:ID="homepage">
<rdfs:rangerdf:resource="http://www.w3.org/2001/XMLSche
ma#
string"/>
</rdf:Property>
A corresponding example of mapping would be:
<Class > <ClasstemplateName="person"rdfLabel="Person"
sql="SELECT*
FROM person p, department d WHERE d.id =
p.id_department">
<PropertytemplateName="surname"rdfLabel="surname"
sqlName
="family_name"/>
</Class>
─ Jena, creates RDF models, the simplest way is by creating a default one:
ModelFactory.createDefaultModel(), and these models are stored in
the memory
─ JRDF stores these triples in a manner similar to Hibernate, as Java Object Api.
Being able to talk directly to a triple store in a common manner with the ability
to swap differing implementations is one of the key aims of the project.
4. 4 Corneliu Dicusar, Petru Rebeja
4 SPARQL Support
─ METAmorphoses does not have a support for SPARQL.
─ Jena uses ARQ8, a query engine that supports SPAQRL. ARQ offers support
for standard SPARQL, and some extensions like SPARQL algebra, also other
features such as:
o Free text search via Lucene9
o SPARQL/Update
o Support for custom filter functions
o Property functions for custom processing of semantic relationships
o Aggregation, GROUP BY and assignment as SPARQL extensions
o Support for federated query
o Support for extension to other storage systems
─ JRDF offers even a separate GUI that makes handling the SPARQL queries
easier, the results being displayed in a tabular form. It also contains the package
org.jrdf.sparql that implements it. And implements the interface
SPARQLConnection - that offers a connection through which to send the query,
and extends the class: DefaulSPARQLConnection and SPARQLQueryBuilder,
which builds queries from string format into Query objects.
5 Support for developers
5.1 Documentation
─ METAmorphoses has a small description on the official site, and also some
examples can be found in the documentation manual. Though the example is
analyzed in an intuitive manner, and working with the tool is like using a simple
Java Library, it doesn’t provide enough information for building complex
applications right away.
─ Jena is documented well enough. Detailed information can be found on the site.
Also they offer support, and if a question appears, one can address it to the
development team.
─ JRDF is also well documented and structured into a tree-like hierarchy
containing all included packages. A very useful thing for a developer who wants
to use this tool
5.2 Integration
All of these tools can be used as Java libraries in a common way. In addition, JRDF
offers a simple GUI.
8
http://jena.sourceforge.net/ARQ/
9 http://lucene.apache.org/
5. RDF processing tools in Java 5
5.3 Learning curve
The learning curve of these tools is common with the learning of other Java Libraries.
Naturally JRDF and Jena, being much more complex, take more time to get used to.
But once classes and functions are learned, you encounter little problems, also due to
the excellent documentation. If you don’t want to use the JRDF API, you could just
instead use JRDF GUI that shortens the time you need to spend, before using the tool.
Unfortunately, until now, no discussion forums were found for these tools using a
Web search.
5.4 Copyright terms
─ METAmorphoses is being developed under the Lesser GPL licence10.
─ Jena is under the licence of Hewlett-Packard Development Company
─ JRDF is under BSD-Licence11
6 Conclusions
Semantic Web is becoming more and more of a reality, and no technology that is
oriented on building software for the Web (with or without a capital w), can afford
ignoring this fact. RDF is a key concept in Semantic Web so it’s only natural that
tools for RDF processing are developed. Java, being one of the most popular
programming languages nowadays, definitely needs such tools. With the need comes
expectance, with expectance comes evolution. The three tools illustrated in this paper
are the most promising (from the author’s point of view) ones in becoming
indispensable libraries for building applications for Semantic Web.
7 References
1. http://www.w3.org/RDF/
2. METAmorphoses v0.2.1: mapping and template language documentation,
http://metamorphoses.sourceforge.net/metamorphoses-v0.2.1_doc.pdf
10
http://www.gnu.org/licenses/lgpl.html
11 http://www.opensource.org/licenses/bsd-license.php