# Redland - RDF Application Framework - Perl Interface

## Installing the Redland Perl interface

This is built if `--with-perl` is given to the configure line, or `--with-perl=perl5.8` to use a particular perl version/program. The standard 'make' at the top level will build it.

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

      cd perl
      make
      make check # optional

To install it system wide (this is optional) do this as root:

      root# make install

The Redland interface has been tested with Perl 5.8.0, 5.6.1, 5.6.0 and (in the past) 5.005 however it probably requires 5.6.0 minimum.

## Testing the Redland Perl interface

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

      perl ./example.pl

Otherwise, to run in the source tree do:

      perl -Iblib/arch -Iblib/lib ./example.pl

and the result should be:

      Creating storage

      Creating model

      Creating statement

      Adding statement to model

      Adding statement (new Statement(n, n, n)) to model

      Adding statement (n,n,n) to model

      Parsing URI (file) dc.rdf
      Parsing added 3 statements

      Printing all statements
      Statement: {[http://example.org/foo], [http://example.org/foo], [http://example.org/foo]}
      Statement: {[http://example.org/foo], [http://example.org/foo], [http://example.org/foo]}
      Statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/title], "Dave Beckett's Home Page"}
      Statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
      Statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
      Statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/description], "The generic home page of Dave Beckett."}

      Searching model for statements matching predicate http://purl.org/dc/elements/1.1/creator
      Matching Statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
        Subject: [http://purl.org/net/dajobe/]
        Predicate: [http://purl.org/dc/elements/1.1/creator]
        Object: Dave Beckett
      Matching Statement: {[http://purl.org/net/dajobe/], [http://purl.org/dc/elements/1.1/creator], "Dave Beckett"}
        Subject: [http://purl.org/net/dajobe/]
        Predicate: [http://purl.org/dc/elements/1.1/creator]
        Object: Dave Beckett

      Searching model for targets of subject http://purl.org/net/dajobe/ predicate http://purl.org/dc/elements/1.1/creator
      Matching Node: Dave Beckett
      Matching Node: Dave Beckett

      Writing model to test-out.rdf as rdf/xml

    Done

## Redland Perl API Introduction

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

Concept | Redland Class | Perl Class | Purpose
--- | --- | --- | ---
Resource / Literal | librdf_node | `RDF::Redland::Node` | RDF Model & Syntax nodes
Statement / Triple | librdf_statement | `RDF::Redland::Statement` | RDF Model & Syntax arcs (statements, triples) [isa Resource]
Model | librdf_model | `RDF::Redland::Model` | Set of Statements usually held in one Storage.
Storage | librdf_storage | `RDF::Redland::Storage` | Storage for Models either persistant or in-memory.
Stream | librdf_stream | `RDF::Redland::Stream` | Providing sequences of Statements from Parsers, queries.
Parser | librdf_parser | `RDF::Redland::Parser` | Syntaxes parsers delivering Stream of Statements or writing to a Model
Serializer | librdf_serializer | `RDF::Redland::Serializer` | Serializes a Model into a syntax such as RDF/XML
Iterator | librdf_iterator | `RDF::Redland::Iterator` | Enumerating lists (of Node) from queries.
URI | librdf_uri | `RDF::Redland::URI` | Provides URIs for Resources, Parsers, ...
World |  | `RDF::Redland` | RDF wrapper class handling Redland startup/shutdown
Digest | librdf_digest |  | Internal content digest class
Hash | librdf_hash |  | Internal key:value maps class
List | librdf_list |  | Internal list class
|  | `RDF::Redland::RSS` | Perl Module providing RSS 1.0 support.

## Perl API Reference Documentation

Either use any of the `RDF::Redland::` module links above or start at the main RDF::Redland module and follow the references from there.

## Other RDF Perl APIs and applications

- Web Resource Application Framework (WRAF) (and at SourceForge) - RDF API that hopes to realize the Semantic Web. The framework uses RDF for data, user interface, modules and object methods. It uses interfaces to other sources in order to integrate all data in one enviroment, regardless of storacdc/apache/etc/age form. Includes the `RDF::Service` perl modules (also in CPAN).
- W3C perl modules by Eric Prud'hommeaux.
- RDFStore - Perl API for RDF storage. A pure Perl implementation of the Draft Java API from the Stanford University DataBase Group by Sergey Melnik with some additional modules to read/write RDF triples directly from the Perl languge environment.
- CARA Perl RDF API by Stefan Kokkelink developed within the CARMEN project.

Copyright 2000-2003 Dave Beckett, Institute for Learning and Research Technology, University of Bristol