modules/rdf/examples/parser-store-sparql.zzm

rdf-0.0.3 source code

=encoding utf8

=head1 NAME

rdf/examples/parser-store-sparql - updating and querying a store with SPARQL

=head1 SYNOPSIS

  from rdf import RDFStore, TurtleParser, sparql_query, sparql_update;
  
  let store := RDFStore.temp();
  store.install_schema();
  
  ( new TurtleParser() ).parse_string( """
    @prefix ex: <http://example.com/> .
    ex:alice ex:name "Alice" .
  """, into: store );
  
  sparql_update( store, """
    PREFIX ex: <http://example.com/>
    INSERT DATA { ex:alice ex:knows ex:bob . }
  """ );
  
  let result := sparql_query( store, """
    PREFIX ex: <http://example.com/>
    ASK { ex:alice ex:knows ex:bob . }
  """ );
  
  say result{boolean} ? "yes" : "no";

=cut