While reading about SPARQL I developed a wordpress plugin (wp-arc) which I’ve decided to release into the public domain. The plugin implements a shortcode interface to the ARC RDF system. To use the plugin you’ll need to install my forms library first. Both plugins can be found here: wp-forms, wp-arc. The lastest verison, wp-arc-latest.zip, contains a few improvements. There was an extra line at the end of the old version of wp-arc.php, which may have caused compilation problems. Also the processing of HTML entities and backslashes has been improved. If you have any problems installing them please let me know because I’ve only tested them on my local installation running wordpress 2.7.1. The interface is minimal but OK for building on.
The shortcode command has four options:
- input = ”form”, “inline” or “file”
- endpoint = ”the SPARQL endpoint”
- rdf = “an rdf filename”
- display = “the query variable to display” – only one variable can be input at present
To display a form for inputing SPARQL queries just create a page containing the following shotcode with the input option set to ‘form’:
[sparql input='form']
[/sparql]
When the form loads you will be presented with a “submit” button and three text fields for inputting the “endpoint”, the “sparql query” and the “variable” to display.
If you don’t want to use the form interface then just input the same shortcode with the options shown below. The SPARQL query should be enclosed between the opening and closing shortcode tags.
[sparql input='inline' endpoint='http://dbpedia.org/sparql'
display='name']
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX : <http://dbpedia.org/resource/>
PREFIX dbpedia2: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT ?name ?birth ?death ?person WHERE {
?person dbpedia2:birthPlace <http://dbpedia.org/resource/Berlin> .
?person dbo:birthdate ?birth .
?person foaf:name ?name .
?person dbo:deathdate ?death
FILTER (?birth < '1900-01-01'^^xsd:date) .
}
[/sparql]
The triples in an RDF file can be displayed by inputting the following shortcode and options.
[sparql input='file' rdf='http://foafbuilder.qdos.com/people/andrew.ritz.myopenid.com/foaf.rdf']
[/sparql]
Sorry about the lack of documentation for these plugins. I promise to rectify the situation when time permits. I also intend to increase the number of options.
One last thing, you may need to encode the HTML entities within your sparql queries that you quote with shorcode tags. You can do that here.
Filed under: Enabling Technologies, plugin, rdf, semantic web, sparql, wordpress
Hello – i’m using your plugin on WordPress 2.8. Thanks.
Having the shortcode form the form [sparql input='form'] [/sparql] on a page, i always get NO CLASS FOUND as result. Any idea why. Is it bad request (i use requests that normally return results).
Thanks.
Exemple. Putting:
SELECT ?name ?birth ?death ?person WHERE {
?person dbpedia2:birthPlace .
?person dbo:birthdate ?birth .
?person foaf:name ?name .
?person dbo:deathdate ?death
FILTER (?birth < \\\'1900-01-01\\\'^^xsd:date) .
}
in the form and asking for name, i get NO CLASS FOUND.