sparql complete tree from subject

Viewed 1107

When I have for example a person graph e.g. John and john has a work adress home adress phone numbers relations etc.

Is it possible to retrieve everything that is connected to john and to the subclasses of john without knowing what it is?

So that I can retrieve for example the following

John < address < house_number
     < mobile_number
     < company < address
               < function < office number < etc...

And retrieve this via:
     "John" rdfs:everything ?everything ... as deep as the tree goes.

Or do I need to know the graph?

2 Answers

This is a nice solution from Joshua Taylor it seems on Apache Jena the query is a little different.

SELECT ?o WHERE {
  :john (<>|!<>)+ ?o
}

Else it throws an error "Unresolved prefix :"

Related