This plugin allows to easily specify RDF triples within elements, to produce a RDF graph for the whole generated site.

Stog-rdf is hosted on Github.

  • 0.8.0 [2013/03/20]: Upgrade to Stog 0.8.0.
  • 0.7.0 [2013/02/13]: Minor fixes.
  • 0.6: First numbered release.

To install:

git clone git@github.com:zoggy/stog-rdf.git cd stog-rdf make all install

(you must have OCaml-RDF >= 0.2 installed). This will install the stog-rdf package with ocamlfind.

To use:

stog --package stog-rdf ...

Stog-rdf defines a new rewrite rule associated to level 200, rdf. Each <rdf> node corresponds to a new triple whose subject is the current element url, or the current block id of the current element if the <rdf> node is contained in a XML node with an id attribute.

Another function, associated to level 201, merges all RDF graphs into one graph and dumps this graph into a file. The name of this file is set in the .stog/config-rdf file (default is graph.rdf).

Examples:

... ... ]]>

Subject is the element url, pred is the URI of the predicate (possibly of the form prefix:term). obj is the URI of the object.

... ... ]]>

Subject and predicate are as in the first example. href is of the form hid[#id] to indicate an element of the site, and eventually a node id in this element. This is reduced to the complete URI of the element of element#id.

...

]]>

Here the subject is the URI formed by the element url and the id of the <p> node, for example http://my.example.com/foo/page1.html#id1 if my element has hid foo/page1 and base url of the site is http://my.example.com.

To add the triples, the ...]]> node is rewritten to

[#id]"> ... ]]>

and this XML tree is parsed using OCaml-RDF RDF/XML parser to add the triples to the element graph. If a href or obj attribute was used, the corresponding URI is associated to the `rdf:resource` attribute in the rewritten node:

[#id]"> ... ]]>

and the whole <rdf:Description> node is parsed by the RDF/XML parser.

Namespaces used in RDF triples in the site must be declared in the .stog/config-rdf file.

The rdf and site namespaces don't need to be specified and are automatically handled respectively as

]]>

(the site base url is the one specified with stog-site-url in the main stog element).

To make definition of triples even easier, one can define rules in the element header, for example:

...
...
...
]]>

This will add a triple

#proof1 rdf:hasType science:proof]]>