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
Wed Sep 13 12:21:30 PDT 2006


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



More information about the protege-owl mailing list