Created
September 15, 2010 11:22
-
-
Save samuell/580590 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @title: Testing the Semantic MediaWiki connector plugin | |
* @author: [email protected] | |
**/ | |
// Get RDF Data from Wiki | |
var wikiURL = "http://drugmet.rilspace.org/wiki/"; | |
var rdfXml = smw.getTriples( wikiURL, 0 ); | |
// Write RDF to a local file | |
var now = getDateTimeString(); | |
var rdfXmlFile = "My Test Project/output." + now + ".rdf.xml"; | |
ui.newFile( rdfXmlFile, rdfXml ); | |
// Query the local file with SPARQL | |
var tripleStore = rdf.createStore("rdfStore001"); | |
rdf.importFile( tripleStore2, rdfXmlFile, "RDF/XML" ) | |
var sparqlString = "SELECT ?s WHERE {?s ?p ?o}"; | |
rdf.sparql( tripleStore, sparqlString ); | |
/************** Utility functions ***************/ | |
function getDateTimeString() { | |
var d = new Date(); | |
var now = d.getFullYear() + "-" + | |
pad( d.getMonth(), 2 ) + "-" + | |
pad( d.getDate(), 2 ) + "." + | |
pad( d.getHours(), 2 ) + "." + | |
pad( d.getMinutes(), 2 ) + "." + | |
pad( d.getSeconds(), 2 ); | |
return now; | |
} | |
function pad(number, length) { | |
var str = '' + number; | |
while (str.length < length) { | |
str = '0' + str; | |
} | |
return str; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment