The LinkedWiki extension allows you to embed a SPARQL query and display the results in your wiki page.
Go to the LinkedWik Extension page. Using the links in the box on the right hand side, download the v2.0.1Alpha1 LinkedWiki extension.
Move the downloaded zip file into your MediaWiki extensions folder. You will find this folder in your Virtuoso installation directory/vsp/vad/vsp/MediaWiki/extension. Extract the extension.
The LinkedWiki extension is enabled by adding the following line to the your Virtuoso installation directory/vsp/vad/vsp/MediaWiki/LocalSettings.php file
require_once( "{$IP}/extensions/LinkedWiki/LinkedWiki.php" ); $wgLinkedWikiGraphWiki = 'http://example.org/mydefaultgraphname';
{{#sparql:select * where { ?x ?y ?z . } LIMIT 5 | endpoint=http://localhost:8890/sparql}}
This displays the first 5 triples from the specified endpoint. The results will look something like this:
The properties of the current page can be queried using either of the following:
{{#sparql:PREFIX a:<http://localhost:8890/MediaWiki/index.php?title=Special:URIResolver/> select * where { a:{{PAGENAMEE}} ?y ?z . } | endpoint = http://localhost:8890/sparql }}
or
{{#sparql:select * where { <http://localhost:8890/MediaWiki/index.php?title=Special:URIResolver/{{PAGENAMEE}}> ?y ?z . } | endpoint = http://localhost:8890/sparql }}
The results will look something like:
You can specify which endpoint you want to query so, this example queries the sparql endpoint on dbpedia to find the number of nations participating in each Olympic games:
{{#sparql:select distinct ?Games ?Olympiad ?NumberOfNations {?s a <http://dbpedia.org/ontology/Olympics> . ?s <http://www.w3.org/2000/01/rdf-schema#label> ?Games . ?s <http://dbpedia.org/property/years> ?Olympiad . ?s <http://dbpedia.org/ontology/numberOfParticipatingNations> ?NumberOfNations FILTER (lang(?Games) = "en")} order by ?Games | endpoint = http://dbpedia.org/sparql }}
and returns results something like this:
rows.0.point=43.30, 5.38 | rows.1.point=48.83, 2.3 | rows.2.point=49.93, 2.3
The widget must be able to handle parameters of this form.
One example is a Google maps widget developed specifically for displaying LinkedWiki results. This widget can be found here.
To use the widget to display the results from a sparql query on a map you would do something like this
{{#wsparql:Google_Static_Maps |query=SELECT ?s ?point ?label WHERE { ?s <http://www.georss.org/georss/point> ?point . ?s a <http://schema.org/StadiumOrArena> . ?s <http://www.w3.org/2000/01/rdf-schema#label> ?label . FILTER bif:contains(?label, "Olympic and Stadium") . FILTER (lang(?label) ='en') } limit 20 |endpoint = http://dbpedia.org/sparql |defaultcolor=blue |zoom=2 |size=512x512 |maptype=roadmap}}
The result will be a map embedded in the wiki page that show the location of Olympic stadia around the world.