Redland RDF Application Framework - OCaml Interface

Installing the Redland OCaml interface

This is built if --with-ocaml is given to the configure line, or --with-ocaml=ocamlfind to use a particular ocamlfind program. The standard 'make' at the top level will build it.

You can also compile the ocaml interface by hand as follows:

  cd ocaml
  make

  # optional - runs the tests
  make check

To install it system wide do this as root (or maybe via sudo make install):

  root# make install

The ocaml interface for Redland is experimental and requires OCaml 3.12 or newer. It has been tested with the following versions:

3.12 on OSX/x86
3.12 on Linux/x86

Testing the Redland OCaml interface

If you did the install above, run the ocaml example program with:

  ocamlfind ocamlopt -package camlrdf -o example.opt example.ml -linkpkg
  ./example.opt

and the result should be:

  found statement: {[http://www.dajobe.org/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
  Parsing URI (file) ../data/dc.rdf
  Parsing added 3 statements
  Printing all statements
  Statement: {[http://www.dajobe.org/], [http://purl.org/dc/elements/1.1/description], "The generic home page of Dave Beckett."}
  Statement: {[http://www.dajobe.org/], [http://purl.org/dc/elements/1.1/title], "Dave Beckett's Home Page"}
  Statement: {[http://www.dajobe.org/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
  Statement: {[http://www.dajobe.org/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
  querying for dc:titles:
  {
    a = http://www.dajobe.org/ (RESOURCE)
    c = Dave Beckett's Home Page (LITERAL)
  }
  Writing model to test-out.rdf as rdf/xml

Using the Redland OCaml API

Read the pydoc Redland OCaml API for full details of the classes and methods provided along with examples of use.

The OCaml API is an object-based API reflecting the same structure of the Redland objects with simple mappings between them:

ConceptRedland ClassOCaml ModulePurpose
Resource / Literallibrdf_node Rdf.Node RDF Model & Syntax nodes
Statement / Triplelibrdf_statement Rdf.Statement RDF Model & Syntax arcs (statements, triples) [isa Resource]
Modellibrdf_model Rdf.Model Set of Statement s usually held in one Storage
Storagelibrdf_storage Rdf.Storage Storage for Model s either persistant or in-memory
Streamlibrdf_stream Rdf.Stream Providing sequences of Statement s from Parser s, queries
Parserlibrdf_parser Rdf.Parser Parsing to deliver Stream of Statement s or writing to a Model
Querylibrdf_query Rdf.Query Querying a Model to deliver QueryResults
QueryResultslibrdf_query_results Rdf.QueryResults Results of applying a Query to a Model giving either variable bindings with Node values or Stream of Statement s
Serializerlibrdf_serializer Rdf.Serializer Serializing a Model in a format such as RDF/XML
Iteratorlibrdf_iterator Rdf.Iterator Enumerating Node s from queries.
URIlibrdf_uri Rdf.Uri Providing URIs for Resource s, Parser s, ...
Worldlibrdf_world  RDF wrapper class handling Redland startup/shutdown
Digestlibrdf_digest  Internal content digest class
Hashlibrdf_hash  Internal key:value maps class

Copyright (C) 2012 Codinuum Software Lab, Copyright (C) 2000-2007 Dave Beckett, Copyright (C) 2000-2005 University of Bristol