So I am provided a big XML document. I have to write a query which, given a class name and ontology name, will compute an ontology view which contains the ontology parts of the document which are related to that class. More precisely, I need to select the subclasses of the class, the instances and the rules related to the class. I was thinking of doing this recursively.
Any idea of how can this be done easily?
You can descend the class hierarchy defined in your document via a recursive function:
The function returns nested elements representing the subclass relationships. The subclasses of
Devicefor example can be computed as follows:Result:
You can easily adapt this function to return the respective classes’ rules and instances instead.