On 27/08/13 22:27, thomas wrote:
hey jena folks,

I'm new to this list, so please forgive me if I get something wrong...
my specific questions are at the end of this email, but I wanted to
first describe my problem:

*I am trying to read the latest AIRS OWL (rdf/xml) files, and I'm having
a problem with a particular construct. **
**In AIRSMidLevelOntology.owl, on line 484, I have this:*

<owl:Class rdf:ID="LandlineTelephoneNumber">
     <rdfs:label rdf:datatype="http://www.w3.org/2001/XMLSchema#string";
     >Landline telephone number</rdfs:label>
     <owl:equivalentClass>
       <owl:Restriction>
         <owl:onProperty
rdf:resource="http://www.cubrc.org/ontologies/KDD/Mid/InformationEntityOntology#designates"/>

         <owl:someValuesFrom>
           <owl:Class>
             <owl:intersectionOf rdf:parseType="Collection">
               <rdf:Description
rdf:about="http://www.cubrc.org/ontologies/KDD/Mid/ArtifactOntology#LandlineTelephone"/>

               <owl:Restriction>
                 <owl:onProperty
rdf:resource="http://www.obofoundry.org/ro/ro.owl#part_of"/>
                 <owl:someValuesFrom
rdf:resource="http://www.cubrc.org/ontologies/KDD/Mid/ArtifactOntology#TelecommunicationNetwork"/>

               </owl:Restriction>
             </owl:intersectionOf>
           </owl:Class>
         </owl:someValuesFrom>
       </owl:Restriction>
     </owl:equivalentClass>
     <rdfs:subClassOf>
       <owl:Class rdf:ID="TelephoneNumber"/>
     </rdfs:subClassOf>
   </owl:Class>
*
**but jena throws when i read **this line:*
<rdf:Description
rdf:about="http://www.cubrc.org/ontologies/KDD/Mid/ArtifactOntology#LandlineTelephone"/>


*saying that it can't convert it to a class:*

Uncaught throwable handled
com.hp.hpl.jena.ontology.ConversionException: Cannot convert node
http://www.cubrc.org/ontologies/KDD/Mid/ArtifactOntology#LandlineTelephone
to OntClass: it does not have rdf:type owl:Class or equivalent
     at
com.hp.hpl.jena.ontology.impl.OntClassImpl$1.wrap(OntClassImpl.java:83)
     at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:152)
     at com.hp.hpl.jena.enhanced.EnhNode.convertTo(EnhNode.java:31)
     at
com.hp.hpl.jena.enhanced.Polymorphic.asInternal(Polymorphic.java:62)
     at com.hp.hpl.jena.enhanced.EnhNode.as(EnhNode.java:107)
     at
com.hp.hpl.jena.ontology.impl.OntResourceImpl$AsMapper.map1(OntResourceImpl.java:1657)

     ...


if I change "rdf:Description" to "owl:class" then it works properly, but
I don't think it's doing what I want (in that I don't think it actually
references the external class).

Given that

http://www.cubrc.org/ontologies/KDD/Mid/ArtifactOntology#LandlineTelephone
is being used in an intersection then it presumably is supposed to be a class. So changing rdf:Description to owl:Class won't be doing any harm, however it is not necessary.

The OntAPI by default checks for explicit declarations ("strict mode"). If you have inference turned on those declarations might be inferred. If you imported the referenced ontology by an owl:imports statement or by manually loading it into your jena model then that would supply the declarations.

However, the easy solution is to switch strict mode off:

    jenaModel.setStrictMode( false );

That allows you to treat a resource as a class or property even if there isn't a local declaration for it.

I think it has to do with accessing classes and properties from owl
files elsewhere on the web (note that the rdf:Description is referencing
a class in another file)

in particular, there is a uri that gives a 404 when being referenced.

It works properly when I am accessing only local classes.

I am using this code to load my file:

final OntModel jenaModel = ModelFactory.createOntologyModel(
OntModelSpec.OWL_MEM);
         try {
             jenaModel.read(
                     new FileReader(owlDocument),
                     null
             );


so my questions are:   (and please forgive the naiveté of them, I'm
super new to this!)

(1) does jena automatically download the files referenced throughout the
file?

No. If you explicitly import external files using owl:imports and you load your document as an OntModel with imports processing turned on then the files will be fetched as submodels. There's no implicit import just because a URI is mentioned.

(2) if I need to add a local file for it to reference, is there a way of
loading the main file and the one it references together in a
single read?

If you want to load the referenced files and they are published on the web then use owl:imports. It sounds like yours isn't published at its intended location in which case you could use the OntDocumentManager facilities to map that URL to a local file.

However, switching off strict mode is the easiest solution.

Dave

Reply via email to