1. ww
  2. rdfextras

Overview

RDFExtras README

RDFExtras is a collection of packages providing extras based on RDFLib. These include a tools package and several "non-core-rdflib" store implementations.

Temporary Parking

>>> import rdflib
>>> from rdflib import Graph, BNode, Literal, RDF, plugin, Namespace
>>> FOAF = Namespace("http://xmlns.com/foaf/0.1/")
>>> plugin.register('sparql', rdflib.query.Processor,
>>>                        'rdfextras.ccfsparql', 'Processor')
>>> plugin.register('sparql', rdflib.query.Result,
>>>                        'rdfextras.ccfsparql.QueryResult', 'SPARQLQueryResult')
>>> g = Graph()
>>> p = plugin.get('sparql', rdflib.query.Processor)(g)
>>> g.parse("http://danbri.livejournal.com/data/foaf")
>>> [g.add((s, FOAF['name'], n)) for s,_,n in g.triples((None, FOAF['member_name'], None))]
>>>
>>> results = g.query(
>>>         """SELECT ?aname ?bname
>>>            WHERE {
>>>               ?a foaf:knows ?b .
>>>               ?a foaf:name ?aname .
>>>               ?b foaf:name ?bname .
>>>            }""",
>>>         initNs=dict(foaf=FOAF),
>>>         DEBUG=True)
>>> for row in results:
>>>     # print "%s knows %s" % row
>>>     print "%s" % row