Hi all,

I just started using Jena and so far just used it to parse an ontology from an 
XML file. My problem is that Jena doesn't complain about unmet restrictions.
I'm developing one tool in a toolchain for bootstrapping an ontology from a 
relational database schema. That tool is responsible for translating the schema 
information into an intermediate specification language also developed by me, 
which is then processed by the rest of the toolchain. My idea was to heavily 
base that specification language on OWL, ideally requiring the input just to be 
valid OWL importing a certain "header", in which the actual restrictions are 
formulated.
But when I wrote a small test ontology in which the restrictions formulated 
before (in the same file) _don't_ hold, Jena accepted it without even a 
warning. Did I do something wrong?

So here is my ontology:


<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
     <!ENTITY rdf  "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; >
     <!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#"; >
     <!ENTITY xsd  "http://www.w3.org/2001/XMLSchema#"; >
     <!ENTITY owl  "http://www.w3.org/2002/07/owl#"; >
]>

<rdf:RDF
  xmlns     ="&owl;"
  xmlns:owl ="&owl;"
  xml:base  ="http://example.com/myontology";
  xmlns:rdf ="&rdf;"
  xmlns:rdfs="&rdfs;"
>


<owl:Ontology rdf:about="">
  <owl:imports rdf:resource="http://isnt.accessed"/>
</owl:Ontology>

<owl:Class rdf:ID="TheClass">
  <rdfs:subClassOf>
    <owl:Restriction>
      <owl:onProperty rdf:resource="#theProperty"/>
      <owl:allValuesFrom rdf:resource="#TheCorrectSubClass"/>
    </owl:Restriction>
  </rdfs:subClassOf>
</owl:Class>

<owl:ObjectProperty rdf:ID="theProperty">
  <rdfs:domain 
rdf:resource="https://www.mn.uio.no/ifi/english/research/groups/logid/db2osl#TheClass"/>
  <rdfs:range 
rdf:resource="https://www.mn.uio.no/ifi/english/research/groups/logid/db2osl#TheClass"/>
</owl:ObjectProperty>

<owl:Class rdf:ID="TheCorrectSubClass">
  <rdfs:subClassOf rdf:resource="#TheClass"/>
  <owl:disjointWith rdf:resource="#TheWrongSubClass"/>
</owl:Class>

<owl:Class rdf:ID="TheWrongSubClass">
  <rdfs:subClassOf rdf:resource="#TheClass"/>
  <owl:disjointWith rdf:resource="#TheCorrectSubClass"/> <!-- just to go sure 
-->
</owl:Class>


<rdf:Description rdf:ID="theWrongObject">
  <rdf:type rdf:resource="#TheWrongSubClass"/>
</rdf:Description>

<rdf:Description rdf:ID="theObject">
  <rdf:type rdf:resource="#TheClass"/>
  <theProperty rdf:resource="#theWrongObject"/>
</rdf:Description>


</rdf:RDF>


And here's the code I used:

BasicConfigurator.configure(new ConsoleAppender(new SimpleLayout(), 
ConsoleAppender.SYSTEM_ERR));
final Model model = ModelFactory.createDefaultModel();
model.read("file:///home/phil/test.xml", "RDF/XML");
final InfModel infModel = 
ModelFactory.createInfModel(ReasonerRegistry.getOWLReasoner(), model);
System.err.println("=======================================================================================");
System.err.println("Is valid: " + infModel.validate().isValid());
try {
        model.getWriter().write(model, new FileOutputStream(new 
File("/home/phil/test_jena.xml")), "RDF/XML");
} catch (final Exception e) {
        e.printStackTrace();
}


It accepts the ontology perfectly, giving only "Adding rule [...]" output lines 
and returning true for isValid(). Even name clashes, for example another object 
with the same rdf:ID, are accepted (but with a warning). So I'm a bit confused.

Also, the import doesn't seem to be considered at all: when I change the 
location to one on my webserver, there doesn't appear to be an access.

I read around on this site a bit and also searched the web, especially the 
archive of this list, for answers but couldn't find anything. So please tell me 
if I got or did something wrong or what else is the matter here. Thank you very 
much!


Philipp


PS: The program output:

DEBUG - Adding rule [ (?a rdf:type xsd:integer) -> (?a rdf:type xsd:decimal) ]
DEBUG - Adding rule [ (?x owl:intersectionOf ?y) -> (?x rdf:type owl:Class) ]
DEBUG - Adding rule [ (?a rdf:type owl:Class) -> (?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ symmetricProperty1b: (?Y owl:disjointWith ?X) -> (?X 
owl:disjointWith ?Y) ]
DEBUG - Adding rule [ symmetricProperty1b: (?Y owl:differentFrom ?X) -> (?X 
owl:differentFrom ?Y) ]
DEBUG - Adding rule [ (?x owl:incompatibleWith ?y) notFunctor(?y) -> (?y 
rdf:type owl:Ontology) ]
DEBUG - Adding rule [ (?a rdf:type owl:Ontology) -> (?a rdf:type rdfs:Resource) 
]
DEBUG - Adding rule [ (?x owl:incompatibleWith ?y) -> (?x rdf:type 
owl:Ontology) ]
DEBUG - Adding rule [ (?x owl:backwardCompatibleWith ?y) notFunctor(?y) -> (?y 
rdf:type owl:Ontology) ]
DEBUG - Adding rule [ (?x owl:backwardCompatibleWith ?y) -> (?x rdf:type 
owl:Ontology) ]
DEBUG - Adding rule [ (?x owl:priorVersion ?y) notFunctor(?y) -> (?y rdf:type 
owl:Ontology) ]
DEBUG - Adding rule [ (?x owl:priorVersion ?y) -> (?x rdf:type owl:Ontology) ]
DEBUG - Adding rule [ (?x owl:imports ?y) notFunctor(?y) -> (?y rdf:type 
owl:Ontology) ]
DEBUG - Adding rule [ (?x owl:imports ?y) -> (?x rdf:type owl:Ontology) ]
DEBUG - Adding rule [ (?a rdf:type owl:OntologyProperty) -> (?a rdf:type 
rdf:Property) ]
DEBUG - Adding rule [ (?x owl:onProperty ?y) notFunctor(?y) -> (?y rdf:type 
owl:Property) ]
DEBUG - Adding rule [ (?a rdf:type owl:Property) -> (?a rdf:type rdfs:Resource) 
]
DEBUG - Adding rule [ (?x owl:onProperty ?y) -> (?x rdf:type owl:Restriction) ]
DEBUG - Adding rule [ (?a rdf:type owl:Restriction) -> (?a rdf:type 
rdfs:Resource) ]
DEBUG - Adding rule [ symmetricProperty1b: (?Y owl:sameAs ?X) -> (?X owl:sameAs 
?Y) ]
DEBUG - Adding rule [ (?x owl:disjointWith ?y) notFunctor(?y) -> (?y rdf:type 
owl:Class) ]
DEBUG - Adding rule [ (?x owl:disjointWith ?y) -> (?x rdf:type owl:Class) ]
DEBUG - Adding rule [ (?x owl:equivalentClass ?y) notFunctor(?y) -> (?y 
rdf:type owl:Class) ]
DEBUG - Adding rule [ (?x owl:equivalentClass ?y) -> (?x rdf:type owl:Class) ]
DEBUG - Adding rule [ (?a rdf:type owl:Nothing) -> (?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ (?a rdf:type owl:Nothing) -> (?a rdf:type owl:Thing) ]
DEBUG - Adding rule [ prototype2b: (-3e0986f2:150e21689d5:-7ffe rdf:type ?d) -> 
(owl:Thing rdfs:subClassOf ?d) ]
DEBUG - Adding rule [ (?a rdf:type owl:Thing) -> (?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ (?a rdf:type owl:Restriction) -> (?a rdf:type owl:Class) ]
DEBUG - Adding rule [ (?a rdf:type owl:Class) -> (?a rdf:type rdfs:Class) ]
DEBUG - Adding rule [ (?x owl:oneOf ?y) -> (?x rdf:type owl:Class) ]
DEBUG - Adding rule [ (?a rdf:type owl:SymmetricProperty) -> (?a rdf:type 
owl:ObjectProperty) ]
DEBUG - Adding rule [ (?a rdf:type owl:TransitiveProperty) -> (?a rdf:type 
owl:ObjectProperty) ]
DEBUG - Adding rule [ (?a rdf:type owl:InverseFunctionalProperty) -> (?a 
rdf:type owl:ObjectProperty) ]
DEBUG - Adding rule [ (?a rdf:type owl:DatatypeProperty) -> (?a rdf:type 
rdf:Property) ]
DEBUG - Adding rule [ (?a rdf:type owl:ObjectProperty) -> (?a rdf:type 
rdf:Property) ]
DEBUG - Adding rule [ (?a rdf:type owl:FunctionalProperty) -> (?a rdf:type 
rdf:Property) ]
DEBUG - Adding rule [ (?a rdf:type rdfs:Datatype) -> (?a rdf:type rdfs:Class) ]
DEBUG - Adding rule [ (?a rdfs:isDefinedBy ?b) -> (?a rdfs:seeAlso ?b) ]
DEBUG - Adding rule [ (?a rdf:type rdfs:ContainerMembershipProperty) -> (?a 
rdf:type rdf:Property) ]
DEBUG - Adding rule [ (?a rdf:type rdf:Seq) -> (?a rdf:type rdfs:Container) ]
DEBUG - Adding rule [ (?a rdf:type rdf:Bag) -> (?a rdf:type rdfs:Container) ]
DEBUG - Adding rule [ (?a rdf:type rdf:Alt) -> (?a rdf:type rdfs:Container) ]
DEBUG - Adding rule [ (?x rdf:rest ?y) notFunctor(?y) -> (?y rdf:type rdf:List) 
]
DEBUG - Adding rule [ (?a rdf:type rdf:List) -> (?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ (?x rdfs:range ?y) notFunctor(?y) -> (?y rdf:type 
rdfs:Class) ]
DEBUG - Adding rule [ (?a rdf:type rdfs:Class) -> (?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ (?x rdfs:domain ?y) notFunctor(?y) -> (?y rdf:type 
rdfs:Class) ]
DEBUG - Adding rule [ (?x rdfs:subClassOf ?y) notFunctor(?y) -> (?y rdf:type 
rdfs:Class) ]
DEBUG - Adding rule [ (?x rdfs:subPropertyOf ?y) notFunctor(?y) -> (?y rdf:type 
rdf:Property) ]
DEBUG - Adding rule [ (?a rdf:type rdf:Property) -> (?a rdf:type rdfs:Resource) 
]
DEBUG - Adding rule [ (?x rdf:rest ?y) -> (?x rdf:type rdf:List) ]
DEBUG - Adding rule [ (?x rdf:first ?y) -> (?x rdf:type rdf:List) ]
DEBUG - Adding rule [ (?x rdf:object ?y) -> (?x rdf:type rdf:Statement) ]
DEBUG - Adding rule [ (?x rdf:predicate ?y) -> (?x rdf:type rdf:Statement) ]
DEBUG - Adding rule [ (?x rdf:subject ?y) -> (?x rdf:type rdf:Statement) ]
DEBUG - Adding rule [ (?x rdfs:range ?y) -> (?x rdf:type rdf:Property) ]
DEBUG - Adding rule [ (?x rdfs:domain ?y) -> (?x rdf:type rdf:Property) ]
DEBUG - Adding rule [ (?x rdfs:subClassOf ?y) -> (?x rdf:type rdfs:Class) ]
DEBUG - Adding rule [ (?x rdfs:subPropertyOf ?y) -> (?x rdf:type rdf:Property) ]
DEBUG - Adding rule [ (?a rdf:type rdf:Statement) -> (?a rdf:type 
rdfs:Resource) ]
DEBUG - Adding rule [ (?a rdf:type rdfs:Literal) -> (?a rdf:type rdfs:Resource) 
]
DEBUG - Adding rule [ (?x rdf:type ?y) notFunctor(?y) -> (?y rdf:type 
rdfs:Class) ]
=========================================================================================
DEBUG - Adding rule [ (?x http://example.com/myontology#theProperty ?y) 
notFunctor(?y) -> (?y rdf:type owl:Thing) ]
DEBUG - Adding rule [ (?x http://example.com/myontology#theProperty ?y) -> (?x 
rdf:type owl:Thing) ]
DEBUG - Adding rule [ (?x http://example.com/myontology#theProperty ?y) -> (?x 
rdf:type http://example.com/myontology#TheClass) ]
DEBUG - Adding rule [ (?a rdf:type http://example.com/myontology#TheClass) -> 
(?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ (?x http://example.com/myontology#theProperty ?y) 
notFunctor(?y) -> (?y rdf:type http://example.com/myontology#TheClass) ]
DEBUG - Adding rule [ prototype2b: (-3e0986f2:150e21689d5:-7ffc rdf:type ?d) -> 
(http://example.com/myontology#TheCorrectSubClass rdfs:subClassOf ?d) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheCorrectSubClass) -> (?a rdf:type 
rdfs:Resource) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheCorrectSubClass) -> (?a rdf:type owl:Thing) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheCorrectSubClass) -> (?a rdf:type 
http://example.com/myontology#TheClass) ]
DEBUG - Adding rule [ prototype2b: (-3e0986f2:150e21689d5:-7ffb rdf:type ?d) -> 
(http://example.com/myontology#TheWrongSubClass rdfs:subClassOf ?d) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheWrongSubClass) -> (?a rdf:type rdfs:Resource) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheWrongSubClass) -> (?a rdf:type owl:Thing) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheWrongSubClass) -> (?a rdf:type 
http://example.com/myontology#TheClass) ]
DEBUG - Adding rule [ prototype2b: (-3e0986f2:150e21689d5:-7ffa rdf:type ?d) -> 
(-3e0986f2:150e21689d5:-7fff rdfs:subClassOf ?d) ]
DEBUG - Adding rule [ (?a rdf:type -3e0986f2:150e21689d5:-7fff) -> (?a rdf:type 
rdfs:Resource) ]
DEBUG - Adding rule [ (?a rdf:type -3e0986f2:150e21689d5:-7fff) -> (?a rdf:type 
owl:Thing) ]
DEBUG - Adding rule [ restrictionSubclass1b: (?X rdf:type 
'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) -> 
(?X rdf:type -3e0986f2:150e21689d5:-7fff) ]
DEBUG - Adding rule [ (?a rdf:type 
'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) -> 
(?a rdf:type -3e0986f2:150e21689d5:-7fff) ]
DEBUG - Adding rule [ all1b: (?X http://example.com/myontology#theProperty ?Y) 
(?X rdf:type 'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) -> 
(?Y rdf:type http://example.com/myontology#TheCorrectSubClass) ]
DEBUG - Adding rule [ (?a rdf:type -3e0986f2:150e21689d5:-7fff) -> (?a rdf:type 
'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ all1b: (?X http://example.com/myontology#theProperty ?Y) 
(?X rdf:type -3e0986f2:150e21689d5:-7fff) -> (?Y rdf:type 
http://example.com/myontology#TheCorrectSubClass) ]
DEBUG - Adding rule [ prototype2b: (-3e0986f2:150e21689d5:-7ff9 rdf:type ?d) -> 
(http://example.com/myontology#TheClass rdfs:subClassOf ?d) ]
DEBUG - Adding rule [ (?a rdf:type http://example.com/myontology#TheClass) -> 
(?a rdf:type owl:Thing) ]
DEBUG - Adding rule [ (?a rdf:type http://example.com/myontology#TheClass) -> 
(?a rdf:type -3e0986f2:150e21689d5:-7fff) ]
DEBUG - Adding rule [ (?a rdf:type http://example.com/myontology#TheClass) -> 
(?a rdf:type 'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ all1b: (?X http://example.com/myontology#theProperty ?Y) 
(?X rdf:type http://example.com/myontology#TheClass) -> (?Y rdf:type 
http://example.com/myontology#TheCorrectSubClass) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheCorrectSubClass) -> (?a rdf:type 
'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ (?a rdf:type 
http://example.com/myontology#TheWrongSubClass) -> (?a rdf:type 
'all(http://example.com/myontology#theProperty 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ all1b: (?X http://example.com/myontology#theProperty ?Y) 
(?X rdf:type http://example.com/myontology#TheWrongSubClass) -> (?Y rdf:type 
http://example.com/myontology#TheCorrectSubClass) ]
DEBUG - Adding rule [ validationIndiv: (?I rdf:type 
http://example.com/myontology#TheCorrectSubClass) (?I rdf:type 
http://example.com/myontology#TheWrongSubClass) noValue(?T rb:prototype ?I) -> 
(?I rb:violation 'error('conflict' 'Individual a member of disjoint classes' 
http://example.com/myontology#TheCorrectSubClass 
http://example.com/myontology#TheWrongSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: (?I rdf:type 
http://example.com/myontology#TheWrongSubClass) (?I rdf:type 
http://example.com/myontology#TheCorrectSubClass) noValue(?T rb:prototype ?I) 
-> (?I rb:violation 'error('conflict' 'Individual a member of disjoint classes' 
http://example.com/myontology#TheWrongSubClass 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: 
(http://example.com/myontology#TheWrongSubClass owl:disjointWith 
http://example.com/myontology#TheCorrectSubClass) 
(http://example.com/myontology#TheWrongSubClass rdfs:subClassOf 
http://example.com/myontology#TheCorrectSubClass) -> 
(http://example.com/myontology#TheWrongSubClass rb:violation 
'warn('Inconsistent class' 'Two classes related by both subclass and disjoint 
relations' 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: 
(http://example.com/myontology#TheCorrectSubClass owl:disjointWith 
http://example.com/myontology#TheWrongSubClass) 
(http://example.com/myontology#TheCorrectSubClass rdfs:subClassOf 
http://example.com/myontology#TheWrongSubClass) -> 
(http://example.com/myontology#TheCorrectSubClass rb:violation 
'warn('Inconsistent class' 'Two classes related by both subclass and disjoint 
relations' 
http://example.com/myontology#TheWrongSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: 
(http://example.com/myontology#TheWrongSubClass owl:disjointWith 
http://example.com/myontology#TheCorrectSubClass) (?C rdfs:subClassOf 
http://example.com/myontology#TheWrongSubClass) (?C rdfs:subClassOf 
http://example.com/myontology#TheCorrectSubClass) notEqual(?C owl:Nothing) -> 
(?C rb:violation 'warn('Inconsistent class' 'subclass of two disjoint classes' 
http://example.com/myontology#TheWrongSubClass 
http://example.com/myontology#TheCorrectSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: 
(http://example.com/myontology#TheCorrectSubClass owl:disjointWith 
http://example.com/myontology#TheWrongSubClass) (?C rdfs:subClassOf 
http://example.com/myontology#TheCorrectSubClass) (?C rdfs:subClassOf 
http://example.com/myontology#TheWrongSubClass) notEqual(?C owl:Nothing) -> (?C 
rb:violation 'warn('Inconsistent class' 'subclass of two disjoint classes' 
http://example.com/myontology#TheCorrectSubClass 
http://example.com/myontology#TheWrongSubClass)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: (?I rdf:type owl:Nothing) noValue(?T 
rb:prototype ?I) -> (?I rb:violation 'error('conflict' 'Individual a member of 
Nothing' ?I)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationDTP: (?X 
http://example.com/myontology#theProperty ?V) isLiteral(?V) -> (?X rb:violation 
'warn('range check' 'Literal value for object property (prop, value)' 
http://example.com/myontology#theProperty ?V)'^^urn:x-hp-jena:Functor) ]
DEBUG - Adding rule [ validationIndiv: (?X owl:differentFrom ?Y) (?X owl:sameAs 
?Y) noValue(?T rb:prototype ?X) -> (?X rb:violation 'error('conflict' 'Two 
individuals both same and different, may be due to disjoint classes or 
functional properties' ?Y)'^^urn:x-hp-jena:Functor) ]
Is valid: true

Reply via email to