Search Mailing List Archives


Limit search to: Subject & Body Subject Author
Sort by: Reverse Sort
Limit to: All This Week Last Week This Month Last Month
Select Date Range     through    

[protege-discussion] accessing an OWL file with Java and dom4j

Matthew Horridge matthew.horridge at cs.man.ac.uk
Mon Apr 16 02:04:29 PDT 2007


>
> I hope this is the right mailing list, apologies if not.
>
> I created a ontology with Protege Frames, and used the built in  
> export function to export the ontology to OWL.
>
> I am currently using dom4j with Java to search the ontology, and I  
> am having two problems:
>

I think you would be much better using an API for OWL ontologies such  
as the Protege-OWL API, Jena or the OWL API.  You shouldn't and can't  
really examine an ontology with something like dom4j.  If you want to  
obtain the instances of a class then you really should use an API  
which provides access to a DL reasoner (see protege-owl docs for more  
details).

Cheers,

Matthew


>
> 1)  It seems that not all instances are displayed, for example it  
> only displays 8 instances of the class convenor (lecturer), when it  
> has 29 instances.
>
> The code is:
> public Document printConvenor() {
>     try {
>      //System.out.println("inside parse methods try block");
>       SAXReader reader = new SAXReader();
>       Document document = reader.read(new File("Modules.owl"));
>
>       Element root = document.getRootElement();
>       //System.out.println("outside for loop");
>       int counter = 0;
>       for (Iterator i = root.elementIterator(); i.hasNext();){
>        Element element = (Element)i.next();
>        //System.out.println(element.getQualifiedName());
>        //System.out.println(element.getTextTrim());
>
>
>        if ((element.elementText("first_name")) != null){
>
>         //Print out module details
>         System.out.print("First Name: ");
>         System.out.println(element.elementText("first_name"));
>         System.out.print("Surname: ");
>         System.out.println(element.elementText("surname"));
>         System.out.print("Room Number: ");
>         System.out.println(element.elementText("room_number"));
>         System.out.print("Website: ");
>         System.out.println(element.elementText("website_address"));
>         System.out.print("User ID: ");
>         System.out.println(element.elementText("user_id"));
>
>         counter++;
>         System.out.println("convenor: " + counter);
>         System.out.println();
>        }else{
>
>         //Do Nothing
>
>        }//end if else if
>
>       }//end for loop
>
> How do I print all the instances?
>
> 2) I have relationships between classes, and in the exported OWL  
> file this is shown as: "modulesFramesNEW_Instance_10045"  how can I  
> access that using Java?
>
> Thank you,
>
> Vishal
>
> Yahoo! Answers - Got a question? Someone out there knows the  
> answer. Try it now.
> _______________________________________________
> protege-discussion mailing list
> protege-discussion at lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-discussion
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/ 
> faq.html#01a.03




More information about the protege-discussion mailing list