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

Tania Tudorache tudorache at stanford.edu
Wed Sep 13 15:30:29 PDT 2006


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
>
>  
>




More information about the protege-owl mailing list