pelican-rdf plugin ================== A plugin for rdf vocabularies providers --------------------------------------- # Overview This plugin is intended at easing the lightwheight description of vocabularies online, in the fashion of http://vocab.linkeddata.es/. It offers a new media type, the Vocabulary, and a flexible mechanism to gather metadata about said vocabulary based on sparql queries. # How it works ## Required configuration ### Description of the variables Your pelicanconf.py should include new options : - **VOC_PATHS**: A list of paths to a local folders containing vocabularies. If all your vocabularies are remote, set its value to an empty list. - **VOC_EXCLUDES**: A list of paths to folders where you don't want vocabularies to be processed. - **VOC_URIS** = A list of URLs pointing to dereferencable vocabularies. Content is negociated to retrieve RDF/XML. - **VOC_QUERIES_PATH** = Path th the folder containing the sparql queries to collect metadata about the vocabulary. - **VOCABULARY_URL**= How the generated document URL should look like - **VOCABULARY_SAVE_AS**= How the generated document should be named ### Default configuration ``` VOC_PATHS=['ontologies'] VOC_EXCLUDES=[] VOC_URIS = ["https://www.irit.fr/recherches/MELODI/ontologies/IoT-O",] VOC_QUERIES_PATH = "plugins/pelican-rdf/sparql-queries" VOCABULARY_URL= '{slug}.html' VOCABULARY_SAVE_AS= '{slug}.html' ``` ## Accessing the vocabulary metadata ### First, a simple example... The following snippet of code outputs a description of the vocabularies that have been processed : ```

Ontology repository

{% if vocabularies %} {% for voc in vocabularies %} {% endfor %}
Title Description License (if any)
{{ voc.title }}
{{ voc.description }}
{{ voc.lov_metadata.license }}
{% endif %} ``` ### ... but how does it work ? The required properties (iri, title, version and description) are directly available in the vocabulary metadata. Notice that the license is accessed through a compound notation, explained in the next paragraph. ### Another example... The following snippet outputs a list of the classes defined by the ontology, as well as its superclass (limited to one for the time being) and potential description (the comment). ``` {% for class in voc.classes %}

{{ class.class }}

{{ class.superclass }}

{{ class.comment }}

{% endfor %} ``` ### ... with custom metadata To understand the example, one must look at the classes.sparql (the name is important) query : ``` PREFIX owl: PREFIX dc: PREFIX cc: PREFIX rdfs: SELECT ?class ?comment ?label ?superclass WHERE { ?class rdf:type owl:Class. OPTIONAL { ?class rdfs:comment ?comment.} OPTIONAL { ?label rdfs:label ?label.} OPTIONAL { ?class rdfs:subClassOf ?superclass.} } GROUP BY ?class ``` Each graph binding matching this sparql query is returned as a dictionnary in the vocabulary context, with the sparql projection attributes (here, class, comment, label and superclass) as keys. Then, this list of results is stored in the vocabulary metadata under the name of the query, here "classes". **NOTE**: The management of multiple values such as the multiple superclasses for a class is not yet handled correctly, it is a work in progress.