For the SPARQL part you have to look at Bob's post, but here is a
basic example how to parse, inspect and modify a collection:
from rdflib import Graph, Literal, URIRef
from rdflib.collection import Collection
g = Graph()
g.parse(data = '''<urn:thing> <urn:prop> ( 1 2 3 ) . ''', format="turtle")
collection_resource = g.value(URIRef('urn:thing'), URIRef('urn:prop'))
collection = Collection(g, collection_resource)
print list(collection)
collection.append(Literal(4))
print g.serialize(format='turtle')
(
https://gist.github.com/gromgull/08bf58ceceef89d464ed)
This API could be better, it would be nice with a method on graph
objects to return a collection, like we have for Resource and Seq (but
not for Alt and Bag oddly enough)
If you just want to read the list, there is graph.items, which will
give you a generator.
- Gunnar
> --
>
http://github.com/RDFLib
> ---
> You received this message because you are subscribed to the Google Groups
> "rdflib-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to
rdflib-dev+...@googlegroups.com.
> To post to this group, send email to
rdfli...@googlegroups.com.
> To view this discussion on the web visit
>
https://groups.google.com/d/msgid/rdflib-dev/9e6615fd-364c-4c2a-b406-3516aff6f8d2%40googlegroups.com.
> For more options, visit
https://groups.google.com/d/optout.
--
http://gromgull.net