I have an owl file I built in Protege. What is the sparql query which will select all the subclasses of a class and all the subclasses of those subclasses, so on and so on (Breadth First Search Sort of Manner)?
相关问题
- Creating a SPARQL parameterized query using append
- Getting list of persons using SPARQL dbpedia
- How can I optimize a SPARQL query that returns opt
- Calculate the depth of subclass in the OWL ontolog
- How to get the terminal leaves of a Wikipedia root
相关文章
- The difference between blank nodes and variables i
- How to display alert box when no json value is giv
- How to turn a SPARQL/SPIN query/rule into an RDF s
- Meaning of owl:hasValue?
- boundary for arbitrary property path in SPARQL 1.1
- sparql complete tree from subject
- Jena Fuseki assembler file + TDB + OWL reasoner
- How to get abstract and thumbnail of a Wikipedia a
This might be answered by Sparql query Subclass or EquivalentTo, but that question and its answer contain a lot more information that what you're asking for here. You can't really enforce the search strategy (depth first vs. depth first), but you can (sort of) order subclasses by their distance from the root, if there's a unique path from the root to the subclass. First, let's get some sample data:
You can use a query like this to get the subclasses of
:a
:The results include
:a
because we used the pathrdfs:subClassOf*
. This is logically correct, since a class is a subclass of itself, but if you don't want:a
included, you could userdfs:subClassOf+
, or you could filter out:a
withfilter( ?subclass != :a )
.In the case that there's a single path from the root to the subclass, you can count the intermediate nodes between them to determine their depth. If you order by depth in this way, then you'll get your results in something like what a breadth first search would give you the following. This technique is described in more detail in Is it possible to get the position of an element in an RDF Collection in SPARQL? and Calculate length of path between nodes?.