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-owl] subclass list with hierarchy in multiple OWL files

Mircea Trifan mircea at ncct.uottawa.ca
Thu Sep 14 07:35:08 PDT 2006


Thanks Tania, it worked perfectly.

Cheers,
Mircea

Tania Tudorache wrote:

> I guess you are right, it may be a namespace problem, if the import is 
> working fine.
>
> Try the following call:
>
> OWLNamedClass owlThingClass = owlModel.getOWLNamedClass("psys:Entity");
>
> If you specify only the short name of the class (like "Entity" or 
> "Abstract"), you can get the OWL classes only for the classes in the 
> default namespace. If Entity is not in the default namespace, then you 
> will have to add also its prefix. (Check which prefix does Protege 
> allocate to the protons namespace. I suppose it is "psys").
>
> Tania
>
>
>
>
> Mircea Trifan wrote:
>
>>
>> Tania,
>>
>> Thanks for your answer and for the getSubclasses tip ;). I was able 
>> to load protont.owl with no problems in the Protege GUI, the classes 
>> are shown correctly and the import trace is below:
>>
>> [ProtegeOWLParser] Importing 
>> http://proton.semanticweb.org/2005/04/protons (from
>> http://proton.semanticweb.org/2005/04/protons [actual ontology at 
>> this location
>> : http://proton.semanticweb.org/2005/04/protons#])
>> [ProtegeOWLParser] Completed triple loading after 1375 ms
>> [TripleChangePostProcessor] Completed lists after 0 ms
>> [TripleChangePostProcessor] Completed anonymous classes after 0 ms
>> [TripleChangePostProcessor] Completed deprecated classes after 0 ms
>> [TripleChangePostProcessor] Completed properties after 16 ms
>> [TripleChangePostProcessor] Completed named classes after 15 ms
>> ... Loading completed after 1437 ms
>>
>> It appears the protons import is loaded over http. I have also a 
>> local copy of this file. The owlModel at debug time is not null and 
>> if I test my little program with a class from protont.owl: E.g. 
>> "Abstract" the subclasses are listed correctly. Isn't it a namespace 
>> problem? What is the other method for loading the owl ontology you 
>> mention at the end of your message.
>>
>> Thanks again.
>>
>> Cheers,
>> Mircea
>>
>> Tania Tudorache wrote:
>>
>>> Mircea,
>>>
>>> It is an interesting way to get the subclasses of a class :) Do you 
>>> have anything against the simpler method:
>>>    cls.getSubclasses(boolean transitive)  ?
>>>
>>> Anyway, this does not have anything to do with the null pointer 
>>> exception. If you get it, it means that the owlModel is null.
>>>
>>> Are you able to load the protont.owl ontology in Protege GUI?
>>>
>>> What I suspect that it happens, is that the imported ontology is not 
>>> found for some reason (either it is not at that location, or it is 
>>> there, but you are not online, or something like that). You can see 
>>> from the console of the Protege GUI (when you load it through the 
>>> GUI) from which location the imported ontology is loaded. If it is a 
>>> local directory, than you will need to use another method to load 
>>> the owl ontology that takes into consideration also the ontology 
>>> repository file.
>>>
>>> Tania
>>>
>>>
>>> Mircea Trifan wrote:
>>>
>>>  
>>>
>>>> Hi,
>>>>
>>>> I'm trying to list the subclasses of a class: Entity defined in one 
>>>> OWL file (protons.owl below) and having the children defined in a 
>>>> different OWL file (protont.owl) that imports the first one. In 
>>>> order to do this when I try to construct an OWLNamedClass from the 
>>>> class name a null pointer is returned and an exception is raised. 
>>>> Any help is greatly appreciated.
>>>>
>>>> Thanks + regards,
>>>> Mircea
>>>>
>>>> public class ClassBrowser {
>>>>
>>>>   /**
>>>>    * @param args
>>>>    */
>>>>   public static void main(String[] args) {
>>>>       // TODO Auto-generated method stub
>>>>
>>>>       OWLModel owlModel;
>>>>       try {
>>>>           owlModel = ProtegeOWL
>>>>                   
>>>> .createJenaOWLModelFromURI("file:///C:/kim-platform/context/default/kb/owl/protont.owl"); 
>>>>
>>>>                   
>>>> //.createJenaOWLModelFromURI("file:///C:/Mircea/OntoIR/entity.owl");
>>>>
>>>>           RDFProperty subClassOfProperty = owlModel
>>>>                   .getRDFProperty(RDFSNames.Slot.SUB_CLASS_OF);
>>>>           String node = "Entity";
>>>>           OWLNamedClass owlThingClass = 
>>>> owlModel.getOWLNamedClass(node);   <<<<<<<<<< NULL
>>>>           Collection results = 
>>>> owlModel.getRDFResourcesWithPropertyValue(
>>>>                   subClassOfProperty, owlThingClass);
>>>>           System.out.println("Subclasses of owl:" + node + ":");
>>>>           for (Iterator it = results.iterator(); it.hasNext();) {
>>>>               RDFResource resource = (RDFResource) it.next();
>>>>               System.out.println(" - " + resource.getBrowserText());
>>>>           }
>>>>       } catch (Exception e) {
>>>>           // TODO Auto-generated catch block
>>>>           e.printStackTrace();
>>>>       }
>>>>   }
>>>>
>>>> }
>>>>
>>>> protons.owl:
>>>> ==============
>>>> <?xml version='1.0' encoding='UTF-8'?>
>>>> <!DOCTYPE owl [
>>>>   <!ENTITY rdf  'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
>>>>   <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
>>>>   <!ENTITY owl  'http://www.w3.org/2002/07/owl#' >
>>>>   <!ENTITY xsd  'http://www.w3.org/2001/XMLSchema#' >
>>>>   <!ENTITY psys  'http://proton.semanticweb.org/2005/04/protons#'>
>>>> ]>
>>>> <rdf:RDF
>>>>   xmlns:owl="&owl;"
>>>>   xmlns:rdf="&rdf;"
>>>>   xmlns:rdfs="&rdfs;"
>>>>   xmlns:psys="&psys;"
>>>>   xmlns="&psys;"
>>>>   xml:base="&psys;"
>>>>   <owl:Ontology rdf:about="">
>>>> <rdfs:comment>PROTON (Proto Ontology), System module</rdfs:comment>
>>>> <owl:versionInfo>"0.1"</owl:versionInfo>
>>>> </owl:Ontology>
>>>>
>>>> <owl:Class rdf:about="#Entity"
>>>>    rdfs:label="Entity">
>>>>   <rdfs:comment>Any sort of an entity of interest, usually 
>>>> something existing, happening, or purely abstract. Entities may 
>>>> have several - more than one - names or aliases.</rdfs:comment>
>>>> </owl:Class>
>>>> ...
>>>>
>>>> protont.owl:
>>>> =============
>>>> <?xml version='1.0' encoding='UTF-8'?>
>>>> <!DOCTYPE owl [
>>>>   <!ENTITY rdf  'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
>>>>   <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
>>>>   <!ENTITY owl  'http://www.w3.org/2002/07/owl#' >
>>>>   <!ENTITY xsd  'http://www.w3.org/2001/XMLSchema#' >
>>>>   <!ENTITY psys  'http://proton.semanticweb.org/2005/04/protons#'>
>>>>   <!ENTITY ptop  'http://proton.semanticweb.org/2005/04/protont#'>
>>>> ]>
>>>> <rdf:RDF
>>>>   xmlns:owl="&owl;"
>>>>   xmlns:rdf="&rdf;"
>>>>   xmlns:rdfs="&rdfs;"
>>>>   xmlns:psys="&psys;"
>>>>   xmlns:ptop="&ptop;"
>>>>   xmlns="&ptop;"
>>>>   xml:base="&ptop;"
>>>>   <owl:Ontology rdf:about="">
>>>> <rdfs:comment>PROTON (Proto Ontology), Top module</rdfs:comment>
>>>> <owl:imports 
>>>> rdf:resource="http://proton.semanticweb.org/2005/04/protons"/>
>>>> <owl:versionInfo>"0.1"</owl:versionInfo>
>>>> </owl:Ontology>
>>>>
>>>> <owl:Class rdf:about="#Abstract"
>>>>    rdfs:label="Abstract">
>>>>   <rdfs:comment>Something, which neither happens nor exists, e.g. a 
>>>> number or a chemical compound formula. Those are usually some 
>>>> symbols, invented to refer to general notions.</rdfs:comment>
>>>>   <rdfs:subClassOf rdf:resource="&psys;Entity"/>
>>>> </owl:Class>
>>>> ...
>>>> _______________________________________________
>>>> protege-owl mailing list
>>>> protege-owl at lists.stanford.edu
>>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>>
>>>>
>>>>
>>>>   
>>>
>>>
>>>
>>> _______________________________________________
>>> protege-owl mailing list
>>> protege-owl at lists.stanford.edu
>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>  
>>>
>>
>>
>




More information about the protege-owl mailing list