[Pellet-users] Fwd: Problem getting hasValue restrictions within superclasses

Horst Gutmann zerok at zerokspot.com
Tue Feb 26 14:59:10 UTC 2008


OK, thank you :-) I'm already using this workaround, just was curious
 if I had missed an entry in the FAQ ... which obviously was the case,
 sorry :-)

 LG, Horst


 On Tue, Feb 26, 2008 at 2:29 PM, Evren Sirin <evren at clarkparsia.com> wrote:
 > Pellet will not return restrictions defined on superclasses. See this
 >  FAQ entry:
 >  http://pellet.owldl.com/faq/different-results/
 >
 >  The workaround would be to iterate through the superclasses and collect
 >  all the asserted restrictions defined on each superclass.
 >
 >  Cheers,
 >  Evren
 >
 >
 >
 >
 >  On 2/26/08 2:41 AM, Horst Gutmann wrote:
 >  > 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
 >  > _______________________________________________
 >  > Pellet-users mailing list
 >  > Pellet-users at lists.owldl.com
 >  > http://lists.owldl.com/mailman/listinfo/pellet-users
 >  > _______________________________________________
 >  >
 >  > Sponsored by Clark & Parsia, LLC http://clarkparsia.com/
 >  >
 >
 >


More information about the Pellet-users mailing list