-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
sparqlstore: Optionally support blank nodes as <bnode:> URIs #512
Conversation
The 4Store triple store understands <bnode:> URIs as pointing to blank nodes, which makes it possible to query and update them using its SPARQL endpoint.
2a956e9
to
0aac7b0
Compare
Seems to be a nice feature. However, as it is non-standard, other SPARQL stores might have other solutions to this problem. I personally would prefere if one could pass the SPARQLStore a function as If we implement this features, shouldn't we also convert Any ideas on how to find a flexible solution that can be adapted to a specific enpoint? And finally, we should not forget about the |
yupp, i had pretty similar thoughts on this one: maybe the right thing to do is ease the customizability of sparqlstore. This could for example be done by passing a I'm not really sure how common the |
Thanks for the comments! Virtuoso seems to allow So I think turning bNodeAsURI into a function is a great idea, so the SPARQLStore class can work with these various different SPARQL engines. In terms of results, they are returned in XML form, and blank nodes appear as ns:bnode elements. The CastToTerm function already handles those and converts them to rdflib.BNode() instances. The patch I submitted should make SPARQLUpdateStore work the same as SPARQLStore; I haven't actually tested that it does, though. I'm happy to rework this to take a function instead of a boolean, I wonder if you can advise me on how the API should look, though? I thought about renaming 'bNodeAsURI' to 'bnode_as_uri' already, but I thought that it would cause an API break for anyone who is currently calling plugins.sparqlstore.SPARQLStore(..., bNodeAsURI=False, ...). Renaming it bNodeToURI would cause the same thing. So maybe it's best to keep the name the same, and allow it to be either False, or a function that returns the blank node as a string ? |
Worth noting that the BNode.skolemize() and URIRef.deskolemize() methods have been added to RDFLib, implementing the skolemization approach described in the RDF 1.1 spec. This is of course independent from any SPARQL mapping; not sure whether the SPARQL engines recognize these forms these days. Ivan
Ivan Herman |
Suggestion: We add two optional arguments The argument |
Marking I think node_to_sparql should return a string, rather than an rdflib.term.Node. It has to become a string to be embedded in a SPARQL query in any case. I'm not quite sure the purpose of node_from_result -- how would it relate to the current CastToTerm function? Would override it, or extend it? |
String as return value of
|
please have a look at #513 |
* master: PEP8: code cleanup SPARQLStore: fixed dangling { in regexp SPARQLStore deprecated unused bNodeAsURI arg SPARQLStore: added node_to_sparql and node_from_result args, closes #512 PEP8 deprecated sparqlstore.CastToTerm, TraverseSPARQLResultDOM and localName methods sparqlstore: Optionally support blank nodes as <bnode:> URIs
* master: test changed to use _node_from_result instead of CastToTerm PEP8: code cleanup SPARQLStore: fixed dangling { in regexp SPARQLStore deprecated unused bNodeAsURI arg SPARQLStore: added node_to_sparql and node_from_result args, closes #512 PEP8 deprecated sparqlstore.CastToTerm, TraverseSPARQLResultDOM and localName methods sparqlstore: Optionally support blank nodes as <bnode:> URIs
initBindings, contexts, addN, remove, add_graph and remove_graph now call the node_to_sparql customizable function. Some support for BNode graph names added. Add-on for RDFLib#513, see also RDFLib#511, RDFLib#512
query (initBindings), contexts, addN, remove, add_graph and remove_graph now call node_to_sparql. Some support for BNode graph names added. Add-on for RDFLib#513, see also RDFLib#511, RDFLib#512
query (initBindings), contexts, addN, remove, add_graph and remove_graph now call node_to_sparql. Some support for BNode graph names added. Add-on for RDFLib#513, see also RDFLib#511, RDFLib#512
The 4Store triple store understands bnode: URIs as pointing to blank
nodes, which makes it possible to query and update them using its SPARQL
endpoint.
#511