XQuery/List OWL Classes

Motivation
You want a simple XQuery program that will extract all the OWL classes from an OWL file that is coded using RDF.

Method
We will start by just selecting all the classes in the file that have an name. In this example the names are stored in the rdf:ID attribute of the class like the following:



For our example we will use the wine ontology Used in the W3C OWL Guide:

Our XQuery will specifically get all the RDF tags with the "owl:Class" element in the file.

Here is a simple XQuery that returns all the Classes in the wine ontology. To you this script you can load it into a collection such as /db/apps/owl/views/classes.xq and the RDF data files can be loaded into /db/apps/owl/data

/db/apps/owl/views/classes.xq

Sample Results
The results will be an HTML file with a ordered list:

File Path: /db/org/syntactica/apps/owl/data/wine.rdf

Number of Classes = 74

1. AlsatianWine 2. AmericanWine 3. Anjou 4. Beaujolais 5. Bordeaux 6. Burgundy 7. CabernetFranc 8. CabernetSauvignon 9. CaliforniaWine 10. Chardonnay ...

Other Tools
There are several other tools for working with OWL files that are very useful. One is to list all of the properties in an OWL file or list all the properties of a class. These reports can then be used to load the class or property into an XForms application for editing/versioning/workflow and approval.