RDF::LinkedData - A simple Linked Data implementation


Version 0.39_2


For just setting this up and get it to run, you would just use the linked_data.psgi script in this distribution, which again use Plack::App::RDF::LinkedData. If you want to try and use this directly, you'd do stuff like:

        my $ld = RDF::LinkedData->new(store => $config->{store},
                                                                                   endpoint_config => $config->{endpoint},
                                                                                        base_uri => $config->{base_uri}
        $ld->namespaces($config->{namespaces}) if ($config->{namespaces});
        return $ld->response($uri)->finalize;

See Plack::App::RDF::LinkedData for a complete example.


new ( store => $store, model => $model, base_uri => $base_uri, request => $request, endpoint_config => $endpoint_config )

Creates a new handler object based on named parameters, given a store config (recommended usage is to pass a hashref of the type that can be passed to RDF::Trine::Store->new_with_config, but a simple string can also be used) or model and a base URI. Optionally, you may pass a Plack::Request object (must be passed before you call content) and an endpoint_config hashref if you want to have a SPARQL Endpoint running using the recommended module RDF::Endpoint.


Called by Moose to initialize an object.


Returns the RDF::Trine::Model object.


Returns or sets the base URI for this handler.

endpoint ( [ $endpoint ] )

Returns the RDF::Endpoint object if it exists or sets it if a RDF::Endpoint object is given as parameter. In most cases, it will be created for you if you pass a endpoint_config hashref to the constructor, so you would most likely not use this method.

request ( [ $request ] )

Returns the Plack::Request object if it exists or sets it if a Plack::Request object is given as parameter.

etag ( [ $etag ] )

Returns an Etag suitable for use in a HTTP header

helper_properties ( )

Returns the RDF::Helper::Properties object if it exists or sets it if a RDF::Helper::Properties object is given as parameter.


Returns or sets the type of result to return, i.e. page, in the case of a human-intended page or data for machine consumption, or an empty string if it is an actual resource URI that should be redirected.


A node for the requested URI. This node is typically used as the subject to find which statements to return as data. This expects to get a URI object containing the full URI of the node.

count ( $node)

Returns the number of statements that has the $node as subject, or all if $node is undef.

content ( $node, $type)

Will return the a hashref with content for this URI, based on the $node subject, and the type of node, which may be either data or page. In the first case, an RDF document serialized to a format set by content negotiation. In the latter, a simple HTML document will be returned. The returned hashref has two keys: content_type and body. The former is self-explanatory, the latter contains the actual content.

One may argue that a hashref with magic keys should be a class of its own, and for that reason, this method should be considered "at risk". Currently, it is only used in one place, and it may be turned into a private method, get passed the Plack::Response object, removed altogether or turned into a role of its own, depending on the actual use cases that surfaces in the future.

response ( $uri )

Will look up what to do with the given URI object and populate the response object.

namespaces ( { skos => '', dct => '' } )

Gets or sets the namespaces that some serializers use for pretty-printing.


Kjetil Kjernsmo, <>


Please report any bugs or feature requests to bug-rdf-linkeddata at, or through the web interface at I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.


You can find documentation for this module with the perldoc command.

    perldoc RDF::LinkedData

The perlrdf mailing list is the right place to seek help and discuss this module:


  • Use IO::Handle streams when they become available from the serializers.

  • Figure out what needs to be done to use this code in other frameworks, such as Magpie.

  • Make it read-write hypermedia.


This module was started by Gregory Todd Williams <> for RDF::LinkedData::Apache, but has been almost totally rewritten.


Copyright 2010 Gregory Todd Williams and ABC Startsiden AS, 2010-2012 Kjetil Kjernsmo

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.