RDF API for PHP

RAP_Pubby - A Linked Data Frontend for RAP

This document is part of the RAP - Rdf API for PHP documentation.

Radoslaw Oldakowski <radol@gmx.de>
Jan 2008


About

RAP_Pubby can be used to add Linked Data interfaces to RAP models.

Linked Data is a style of publishing data on the Semantic Web that makes it easy to interlink, discover and consume data on the Semantic Web. It allows a wide variety of existing RDF browsers (e.g. Disco , Tabulator , OpenLink Browser ), RDF crawlers (e.g. SWSE , Swoogle ), and query agents (e.g. SemWeb Client Library , SWIC ) to access the data.

RAP_Pubby was orignially inspired by Pubby - A Linked Data Frontend for SPARQL Endpoints.

Features:

 

How It Works

In RDF, resources are identified by URIs. The URIs used in most RDF datasets are not dereferenceable , meaning they cannot be accessed in a Semantic Web browser, but return 404 Not Found errors instead, or use non-dereferenceable URI schemes, as in the fictional URI tag:dbpedia.org,2007:Berlin .

When setting up a RAP_Pubby server for your RDF data, you will configure a mapping that translates those URIs to dereferenceable URIs handled by RAP_Pubby. If your server is running at http://myserver.org:8080/rap-pubby/ , then the Berlin URI above might be mapped to http://myserver.org:8080/rap-pubby/Berlin .

RAP_Pubby will handle requests to the mapped URIs by asking the underlying RAP model for information about the original URI, and passing back the results to the client. It also handles various details of the HTTP interaction , such as the 303 redirect required by Web Architecture, and content negotiation between HTML, RDF/XML and N3 descriptions of the same resource.

 

Installation

  1. The first thing you need to do is to get mod-rewrite to redirect requests to the rap_pubby.php handler script. To do this you need to make sure that the rewrite module is enabled in the Apache configuration file "httpd.conf":

    LoadModule rewrite_module modules/mod_rewrite.so


    And to make sure that output buffering is turned on in the PHP configuration file "php.ini":

    output_buffering = on


  2. You need to edit the ".htaccess" file in the rap-pubby directory. Change the 'RewriteBase' bit to reflect the URI base of the rap-pubbyi directory relative to the htdocs directory of your Apache server. E.g.

    RewriteEngine on
    RewriteBase /rdfapi-php/rap-pubby/ #<---- Edit this
    RewriteRule ^[^\.]*$ rap_pubby.php


    Note: the AllowOverride parameter in "httpd.conf" must be set to allow the use of an .htaccess file in the rap-pubby directory.

  3. Modify the "config.php" file in rap-pubby directory according to your needs (see next section).

Configuration

Include RAP Classes

!!! Required !!! Modify this if your rap-pubby is not installed in RAP subdirectory.


RAP_Pubby Server Configuration

!!! Required !!! The root URL where the RAP_Pubby web application is installed, e.g. http://myserver/mydataset/.

The URI of a resource which description will be displayed as the home page of the RAP_Pubby installation.
NOTE: you have to specify a dataset URI, not a mapped web URI.

 

RAP_Pubby Database Configuration

Note: in order to serve a DbModel the $_PUBBY_DATASET['loadRDF'] parameter must be set to "".

Database connection setting

Name of the RAP DbModel to be served by RAP_Pubby

RAP_Pubby Dataset Configuration

Load an RDF document from the Web or the file system and use it as the data source. If specified, the database connection configured above will be ignored.

!!! Required !!! The common URI prefix of the resource identifiers in the served dataset.
NOTE: Only resources with this prefix will be mapped and made available by RAP_Pubby

If present, only dateset URIs matching this regular expression will be mapped and made available by RAP_Pubby. The regular expression must match everything after the $_PUBBY_DATASET['datasetBase'] part of the URI. For example: datasetBase = 'http://example.org/' and datasetURIPattern = '/(users|documents)\/.*/' This will publish the dataset URI http://example.org/users/alice, but not http://example.org/invoices/5395842 because the URI part invoices/5395842 does not match the regular expression. default value = ''.

If present, this string will be prefixed to the mapped web URIs. This is useful if you have to avoid potential name clashes with URIs already used by the server itself. For example, if the dataset includes a URI http://mydataset/page, and the dataset prefix is http://mydataset/, then there would be a clash after mapping because RAP_Pubby reserves the mapped URI http://myserver/mydataset/page for its own use. In this case, you may specify a prefix like "resource/", which will result in a mapped URI of http://myserver/mydataset/resource/page.
NOTE: the prefix must end with "/"

Links to an RDF document whose prefix declarations will be used in output. You can use the file prefixes.n3 in rap-pubby directory as template. If not specified the prefixes from the input RAP model will be used.

All statements inside the metadata file will be added as metadata to the RDF documents published for this dataset. This feature can be used for instance to add licensing information to your published documents. You can use the file metadata.n3 in rap-pubby directory as template.

If set to true, an owl:sameAs statement of the form <web_uri> owl:sameAs <dataset_uri> will be present in Linked Data output.

 

Pubby HTML Output Setting

URL of the template file used in HTML output

URL of the template file rendering '404 - Not Found' information used in HTML output

Link to directory where template includes (css-files, scripts, images) are located

The name of the project, for display in page titles

A project homepage or similar URL, for linking in page titles

Default language for resource label and short description

The value of these RDF properties, if present in the dataset, will be used as labels and page titles for resources.
NOTE: If multiple properties are present only the first one found (in default language, if specified) will be showed.

The value of these RDF properties, if present in the dataset, will be used as short textual description for resources.
NOTE: If multiple properties are present only the first one found (in default language, if specified) will be showed.

The value of these RDF properties, if present in the dataset, will be used as an image URL to show a depiction of the item.
NOTE: If multiple properties are present only the first one found will be showed.


Using Your Own HTML Templates

In RAP_Pubby you can use your own HTML templates. RAPpubbyHTMLserializer loads an html template file specified in the config.php and replaces the placeholders inside a template with dynamically generated content. Following placeholders are allowed:

Will be replaced with PUBBY_HTML_SER__TEMPL_INCL_DIR constant from config.php Will be replaced with PUBBY_HTML_SER__PROJECT_NAME constant from config.php

Will be replaced with PUBBY_HTML_SER__PROJECT_HOMEPAGE constant from config.php

Will be replaced with the URI of the resource beeing described

Will be replaced with the URI of the resource representation in RDF/XML format. (For URIs of the resource representation in n3 place ##_repURIdata_##?output=n3)

Will be replaced with the value of the label property of the URI beeing described, according to $_PUBBY_HTML_SER['labelProperty'] in config.php

Will be replaced with the value of the comment property of the URI beeing described, according to $_PUBBY_HTML_SER['commentProperty'] in config.php

Will be replaced with the value of the image property of the URI beeing described, according to $_PUBBY_HTML_SER['imageProperty'] in config.php

Will be replaced with table rows containing 'property - property value' pairs of the resource beeing described. The styling of odd and even table rows can be altered in your css file by defining 'odd' and 'even' classes respectively.

 

Use Case Example

RAP_Pubby distribution contains a small use case example showing information about the Web-based Systems Group @ Freie Universität Berlin. To run this example:

You can also view this example online at: http://www4.wiwiss.fu-berlin.de/rap-pubby/