I'm using this Javascript RDF parser.
In the documentation it says to use it accordingly:
getRDFURL(url,func,followSeeAlso)
Downloads and parses RDF from a url.
url is the url to recieve the RDF from, use the full url, not a relative one, or the base url will be wrong.
func is a javascript function to call when the rdf has been processed.
In the file for the parser, I spied this empty variable:
var baseURL='';
and I filled it up like so:
var baseURL='http://localhost:8888/demo/StackOverflow-Europe.rdf';
In my index.html
file I tried to call this parsing script in this way:
<!DOCTYPE html>
<meta charset='utf-8'>
<html>
<head>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<link rel='stylesheet' href='style.css'>
</head>
<body>
<!--
<script type='text/javascript' src='script.js'></script>
-->
<script type='text/javascript' src='parser.js'></script>
</body>
</html>
but finally... nothing happened.
What am I doing wrong?
I guess that's not the right way to call javascript files? Is that it? Or maybe there's another reason.
I'm not so familiar with Javascript.
As Jeen Broekstra said in the comments, the line you use in your html file:
has to only purpose to load the the rdf-parser library.
You can load it directly on the main server
and use your own script.
You can use the official demo as a starter point:
new RDF()
allows you to create an RDF utility objectgetRDFURL('/foaf2.rdf', callback)
loads thefoaf2.rdf
file and set the functioncallback
as a callback, i.e. this function is called when the rdf file has been completely loaded.myRDF.toNTriples()
returns all RDF triples.nm = myRDF.Match(null, null, foafNS + "name","Jim Ley")
returns an array of triples that match the subject/predicate/object pattern.mbox = myRDF.getSingleObject(null, nm[0].subject, foafNS + "mbox", null)
returns the value of the object in the collection of triples that matches the subject/predicate/object pattern, or an empty string if not found.