Tuesday, May 31, 2016

Experiments with rdflib.js -- Sixth experiment

Create the file for the code:

vim exp6.js

Write the code:

var $rdf = require('../rdflib.js');

var store = $rdf.graph()
var timeout = 5000 // 5000 ms timeout
var fetcher = new $rdf.Fetcher(store, timeout)
var url = 'http://bshambaugh.rww.io';
var LDP = $rdf.Namespace('http://www.w3.org/ns/ldp#');

fetcher.nowOrWhenFetched(url, function(ok, body, xhr) {
    if (!ok) {
        console.log("Oops, something happened and couldn't fetch data");
    } else {

   var me = $rdf.sym('http://bshambaugh.rww.io');
   var contains = LDP('contains')
   console.log(contains)
   var friend = store.each(me, contains, undefined)
     // Any one person
        // do something with the data in the store (see below)
   for (var i=0; i<friend.length;i++) {
     console.log(friend[i])
   }
   console.log("I fetched the data");
    }
})
 


Run the code:

node exp6.js 

To get the results:

NamedNode { uri: 'http://www.w3.org/ns/ldp#contains' }
NamedNode { uri: 'http://bshambaugh.rww.io/.acl' }
NamedNode { uri: 'http://bshambaugh.rww.io/profile/' }
NamedNode { uri: 'http://bshambaugh.rww.io/storage/' }
I fetched the data

No comments:

Post a Comment