It depends what exactly you need. You can't do arbitrary recursive queries in SPARQL. See, for instance,
However, you do have access to property paths, which can include repetition. So you can do things like:
select ?person where {
dbpedia:Steve_Jobs (<>|!<>)* ?person .
?person a dbpedia-owl:Person .
}
limit 10
Part of the trick here is that (<>|!<>)
acts as a property wildcard, since every property is either <>
or it isn't. That query, I think, should do roughly what you want. However, Virtuoso's SPARQL endpoint doesn't like it, and returns the error:
Virtuoso 37000 Error SP031: SPARQL compiler: Variable '_::trans_subj_4_0' is used in the query result set but not assigned
SPARQL query:
define sql:big-data-const 0
#output-format:text/html
define sql:signal-void-variables 1 define input:default-graph-uri <http://dbpedia.org> select * where {
dbpedia:Steve_Jobs (<>|!<>)* ?person .
?person a dbpedia-owl:Person .
}
limit 10
The query captures what you'd want it to, but you might have to check with the Virtuoso developers to figure out what to do to make it work. If you don't use the wildcard properties, then you'll get result, so if you have a particular set of properties that you care about, you could use it instead. E.g.,
select ?person where {
dbpedia:Steve_Jobs (dbpedia-owl:child|dbpedia-owl:influenced|^dbpedia-owl:child|^dbpedia-owl:influenced)* ?person .
}
limit 10
SPARQL results