我想将一些OWL-S条件强制转换为SWRL,强制转换已完成,但结果操作返回nullpointerexception。这里的代码:
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()){...........
最后一行返回:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
有人能帮我处理这个吗?
此问题与java代码无关,而是与OWLS-S文件语法有关。您可以通过替换来解决此问题:
<expr:expressionBody rdf:parseType="Literal">
保存SWRL前提条件(或最终结果(,通过:
<expr:expressionObject>