Question
Are there practical use cases for negated SPARQL property paths?
I use sparql property paths regularly, but I recently realized that I never seem to have a use for the negation operator, which matches a path if it does not involve the specified property or property set.
?source !ex:property ?target
Unlike the case with negated character ranges ([^abcd]
) for text search, I can't seem to think of any use cases that would need this. The example in the SPARQL Recommendation is no help:
Negated Property Paths: Find nodes connected but not by rdf:type (either way round):
{ ?x !(rdf:type|^rdf:type) ?y }
Research: I found this SO answer where it's used to work around the lack of variables in sparql path by matching for (x or !x)
. But this only uses negation for lack of anything more appropriate.
So are there realistic use cases that I am overlooking, where one needs to look for all-but a certain property or property set in a path? Or is the negation operator hardly ever used in practice?