RDF using Jena as a Parser

In this article, I am going to explain RDF as it related to Jena API.

During the course of working with RDF files, I came across lot's of concepts that really look lame to my understanding of how to implement the Jena API in parsing RDF files. Questions such as ;

  1. What is a Model?
  2. What is a Resource?
  3. What is a Statement?
  4. What is a Literal?
  5. What is a Subject?
  6. What is a Predicate?
  7. What is a Triple?
  8. What is a Blank node?
  9. What is an RDF Graph?
  10. What is a RDF URI Reference?

Openly enough, if you were to crack the workings of how RDF works, it will be a different task if you have not explored and understood the RDF core semantics, syntax and concepts document. RDF may be used with any datatype definition that conforms to the relational database abstraction, even if not defined in terms of XML Schema.

 

What is a Model?

A model is fully formed RDF file. That is, a file that consists of resources, properties and literals. That is, an RDF Graph. An Object consisting of a Subject, predicate and Literal.

 

What is a Resource?

A Resource is an object consisting of a Subject, a predicate and a literal, which is an Object in itself.

In Jena terms, each AResource consists of a subject, a predicate and a literal. The representation of this can be found in the StatementHandler class statement() method.

 

What is a statement?

A statement can be said to be the same as a Triple. That is, the conjunction of a subject, predicate and a literal.

 

What is a Literal?

A Literal is an object made up of a subject and a predicate. i.e subject meaning a node and predicate, the node attribute or property. A literal may be the Object of an RDF statement, but not the Subject  or the predicate.

RDF Literals consists of Plain literals and Typed literals. XML is embedded in RDF using Literals in the format rdf:XMLLiteral.

  • Plain Literals have a lexical form(i.e a UNICODE string) and optionally a language tag. i.e of the form rdf:XMLLiteral or e.g http://example.org
  • Typed Literals have a lexical form and a datatype URI being an RDF URI reference. i.e anyType:XMLLiteral

Note: RDF Literals are distinct and distinguishable from RDF URI references; e.g. http://example.org as an RDF Literal (untyped, without a language tag) is not equal to http://example.org as an RDF URI reference.

In Jena terms, A Literal is made up of key and value. So by implementation, I can say;
Map<String, String> nodevalue = new HashMap<String, String>();

 

What is a Subject?

This is an Object in RDF URI reference format i.e http://example.org

 

What is a Predicate?

That is, property. A Property is a linker between the Subject and the Object.

 

What is a Triple?

This simply means an RDF graph made up of what is called the Subject, Predicate and Object.

RDF Triples contains:

  • the subject, which is an RDF URI reference or a blank node
  • the predicate, which is an RDF URI reference
  • the object, which is an RDF URI reference, a literal or a blank node

 

What is a Blank Node?

Blank node means the node(in XML terms i.e tag) does not have a separate form of identification. hence, it is anonymous.
 

"A blank node is a node that is not a URI reference or a literal. In the RDF abstract syntax, a blank node is just a unique node that can be used in one or more RDF statements, but has no intrinsic name."

Blank nodes are in form of RDF URI references i.e URI e.g http://example.org.

 

What is an RDF Graph?

An RDF graph is a composition of a full blown RDF file. A file that consists of the subject, predicate and an object. An RDF graph is a set of RDF triples.

The nodes of an RDF graph are its subjects and objects.

Quoting the w3 reference found at http://www.w3.org/TR/rdf-concepts/, "A convention used by some linear representations of an RDF graph to allow several statements to reference the same unidentified resource is to use a blank node identifier, which is a local identifier that can be distinguished from all URIs and literals. When graphs are merged, their blank nodes must be kept distinct if meaning is to be preserved; this may call for re-allocation of blank node identifiers. Note that such blank node identifiers are not part of the RDF abstract syntax, and the representation of triples containing blank nodes is entirely dependent on the particular concrete syntax used".

 

What is a RDF URI reference?

An RDF URI reference is a URI of the form http://example.org

Post new comment

The content of this field is kept private and will not be shown publicly.