Is there any solution for processing BNODE in Sesame? for example:
if(! (statement.getObject() instanceof BNode))
tempModel.remove(statement);
if we have an RDF like { s p1 _:a, _:a p2 "value"), therefore even after removing the statement, the second triple will stay in the model. Isn't there any provided solution to handle BNode s in Sesame?
You can just do this:
That will take care of it in most simple cases.
However, if the BNode is the start of an RDF Collection (that is, modeled using a lot of
rdf:first
andrdf:rest
properties, and a lot of blank nodes), you will need something a bit more clever than this, as in this case the object of the second statement can itself also be blank node again.In the current Sesame release you will need to do some manual recursive looping to get this right.
However a utility function to more easily handle RDF Collections is about to be released in Sesame 4.1.0. If you can't wait until official release you can peek at its source code and just copy what it does to get your own custom utility functions for this.