Cast OWL-S condition to SWRL

46 Views Asked by At

I want to cast some OWL-S conditions to SWRL, the cast is done but the result manipulation returns nullpointerexception. Here the code :

final OWLIndividualList<Condition> cs = service.getProfile().getConditions();
final ArrayList<ArrayList<URI>> conditions = new ArrayList<ArrayList<URI>>();
for (final Condition<?> c : cs){
   if (c.canCastTo(Condition.SWRL.class)){ // is it a SWRL condition?
      final Condition.SWRL sc = c.castTo(Condition.SWRL.class);
      for (final Atom a : sc.getBody()){...........

the last line returns :

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

Can anyone help me to deal with this?

1

There are 1 best solutions below

0
On BEST ANSWER

This issue is not linked to the java code but to the OWLS-S file syntaxe. you can resolve this issue by replacing:

 <expr:expressionBody rdf:parseType="Literal">

which hold the SWRL precondition (or eventually the result), by:

<expr:expressionObject>