[Pellet-users] Problem getting hasValue restrictions within superclasses
Horst Gutmann
zerok at zerokspot.com
Tue Feb 26 07:41:44 UTC 2008
Hi everyone :-)
I'm currently having a slightly strange problem. I want to get a list
of all the value restrictions (in this case hasValue) for a given
class in order to render to a UI. The problem is, that with this code,
Pellet (used with Jena) only returns to me the restriction that is set
on properties in the current class but seems to miss all the
restrictions set in superclasses on different datatype properties:
private static Map<OntProperty, Object> getHasValueRestrictions(OntClass c){
Map<OntProperty, Object> result = new Hashtable<OntProperty, Object>();
ArrayList<OntProperty> properties = new ArrayList<OntProperty>();
Iterator<OntClass> scIt = c.listSuperClasses();
Iterator<OntProperty> propIt = c.listDeclaredProperties();
while(propIt.hasNext()){
properties.add(propIt.next());
}
while(scIt.hasNext()){
OntClass sc = scIt.next();
if (!sc.isRestriction()) continue;
if (!sc.asRestriction().isHasValueRestriction()) continue;
Restriction rest = sc.asRestriction();
for(OntProperty p : properties){
if(rest.onProperty(p)){
Object value = sc.asRestriction().asHasValueRestriction()
.getHasValue().asNode().getLiteralValue();
System.out.println(p.getLocalName()+" => "+value.toString());
result.put(p, value);
}
}
}
return result;
}
Any idea what I'm doing wrong here? The same code works as far as I
can tell with Jena's OWL_MEM_RULE_INF and OWL_MEM_TRANS_INF reasoners.
Thanks :-)
Horst
More information about the Pellet-users
mailing list