3
在芝麻中处理BNODE有什么解决方案吗? 例如:芝麻中的BNode解决方案
if(! (statement.getObject() instanceof BNode))
tempModel.remove(statement);
如果我们有一个RDF像{S P1 _:一,_:一P2“值”),因此,即使去掉语句后,二三折会留在模型中。是否有任何提供的解决方案来处理芝麻中的BNode?
在芝麻中处理BNODE有什么解决方案吗? 例如:芝麻中的BNode解决方案
if(! (statement.getObject() instanceof BNode))
tempModel.remove(statement);
如果我们有一个RDF像{S P1 _:一,_:一P2“值”),因此,即使去掉语句后,二三折会留在模型中。是否有任何提供的解决方案来处理芝麻中的BNode?
你可以只是这样做:
tempModel.remove(statement); // remove the first statement
if (statement.getObject() instanceof BNode) {
// remove the second statement
tempModel.remove((BNode)statement.getObject(), null, null);
}
这将照顾它在最简单的情况。但是,如果BNode是RDF集合的开始(即,使用大量的rdf:first
和rdf:rest
属性以及大量空白节点来建模),那么您将需要比这更聪明的东西,因为在这种情况下第二条语句的对象本身也可以再次为空节点。
在当前的Sesame发行版中,您需要做一些手动递归循环才能正确使用。
然而utility function to more easily handle RDF Collections即将在芝麻4.1.0发布。如果你不能等到正式发布,你可以peek at its source code,只是复制它做什么来获得你自己的定制实用功能。