Sessel is a CouchApp for CouchDB that generates RDF triples from JSON documents, which then in turn can be exported to various serialization formats, or queried through a SPARQL endpoint.
Clone this repository and use CouchApp to push Sessel to <your_host>/<your_db>
:
git clone https://github.com/agrueneberg/Sessel.git
couchapp push Sessel/ http://<your_host>/<your_db>
Alternatively, replicate an existing deployment of Sessel to <your_host>/<your_db>
using curl
:
curl\
-X POST\
-H "Content-Type:application/json"\
-d "{\"source\":\"https://couchdb.gutpassfilter.de/sessel\",\
\"target\":\"http://<your_host>/<your_db>\",\
\"filter\":\"vacuum/rw\"}"\
http://localhost:5984/_replicate
The generated triples can be exported to various RDF serialization formats by calling the export interface http://<your_host>/<your_db>/_design/sessel/_rewrite/
with one of the following strings added:
A graphical export interface can be accessed at http://<your_host>/<your_db>/_design/sessel/export.html
.
The default base URI is http://host/db_name/
. If you prefer a different URI, add a base_uri
parameter to the export URL and provide a percent-encoded value, e.g. http://<your_host>/<your_db>/_design/sessel/_rewrite/export.ttl?base_uri=http%3A%2F%2Fexample.com%2Frdf%23
.
The default prefix of the base URI is sessel
. If you prefer a different prefix, add a prefix
parameter to the export URL and provide a value, e.g. http://<your_host>/<your_db>/_design/sessel/_rewrite/export.ttl?base_uri=http%3A%2F%2Fexample.com%2Frdf%23&prefix=example
.
The data types of JSON are mapped to the data types of XML as specified in XML Schema Part 2: Datatypes Second Edition.
string
→xsd:string
array
→xsd:string
object
→xsd:string
null
→xsd:string
number
→xsd:integer
orxsd:double
boolean
→xsd:boolean
To activate data type mapping, add a type_literals
parameter to the export URL and provide a string value true
.
Sessel bundles Antonio Garrote's fantastic rdfstore-js, an RDF store with SPARQL support written entirely in JavaScript. A graphical query interface can be accessed at http://<your_host>/<your_db>/_design/sessel/sparql.html
.
Unfortunately, modern browsers only let rdfstore-js store 5 MB worth of triples. If your data set is large it is recommended to use a standalone SPARQL processor such as ARQ to import the generated triples by pointing it to the export interface:
SELECT *
FROM <http://<your_host>/<your_db>/_design/sessel/_rewrite/export.ttl>
WHERE {
?s ?p ?o .
}
Each JSON document is broken down to key-value pairs. Each key-value pair represents a triple, key and value being predicate and object, respectively. The value of the special key-value pair with the key _id
ensuring the uniqueness of a document serves as the subject of the generated triple.