Skip to content

Developing with RDF

Timea edited this page Feb 17, 2022 · 1 revision

Developping with RDF

useful collection of links

Working with the store

Reading from a resource into the store and writing it out

const $rdf = require('rdflib');                                                       
const store = $rdf.graph();                                                           
const fetcher = $rdf.fetcher(store);                                                  
const uri = 'https://jeffzucker.solidcommunity.net/profile/card';                     
const node = $rdf.sym(uri);                                                           

(async ()=>{                                                                          
  await fetcher.load( uri );                                                          
  console.log( $rdf.serialize(node,store,'text/turtle') );                            
})();

Print-out store content

const $rdf = require('rdflib');                                                       
const store = $rdf.graph();                                                           
const fetcher = $rdf.fetcher(store);                                                  
const uri = 'https://example.com';                                                    
const node = $rdf.sym(uri);                                                           
const ns = $rdf.Namespace(uri+'#');                                                   

(async ()=>{                                                                          
  store.add( ns('A'), ns('B'), ns('C'), node )                                        
  console.log( $rdf.serialize(node,store,'text/turtle') );                            
})();