Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (25 sloc) 901 Bytes
from rdflib import Literal, ConjunctiveGraph, Namespace, BNode
import rdflib
# Note that this example uses SPARQL and assumes you have rdfextras installed
# after installation, no other steps are nescessary, the SPARQL implementation
# should be found automatically.
DC = Namespace(u"")
FOAF = Namespace(u"")
graph = ConjunctiveGraph()
s = BNode()
graph.add((s, FOAF['givenName'], Literal('Alice')))
b = BNode()
graph.add((b, FOAF['givenName'], Literal('Bob')))
graph.add((b, DC['date'], Literal("2005-04-04T04:04:04Z")))
PREFIX foaf: <>
PREFIX dc: <>
PREFIX xsd: <>
SELECT ?name
WHERE { ?x foaf:givenName ?name .
OPTIONAL { ?x dc:date ?date } .
FILTER ( bound(?date) )
for x in graph.query(q):
print x
Jump to Line
Something went wrong with that request. Please try again.