以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  [求助]一个owl的解析问题(jena)  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=30255)


--  作者:cefobid2008
--  发布时间:4/9/2006 9:18:00 PM

--  [求助]一个owl的解析问题(jena)
- <owl:Class rdf:ID="Wine">
  <owl:equivalentClass rdf:resource="http://www.example.org/wine#Wine" />
  </owl:Class>

oc是一个OntClass的实例,这里是Wine
运行
oc.getEquivalentClass()
的时候,因为当前owl的名称空间并不是"http://www.example.org/wine#",所以jena不能识别出Wine是一个类,会报错:
Exception in thread "main" com.hp.hpl.jena.ontology.ConversionException: Cannot convert node http://www.example.org/wine#Wine to OntClass: it does not have rdf:type owl:Class or equivalent

请问怎么解决这种情况?


--  作者:cefobid2008
--  发布时间:4/9/2006 9:20:00 PM

--  
前面定义了名称空间
vin=http://www.example.org/wine#
--  作者:jpz6311whu
--  发布时间:4/10/2006 4:43:00 PM

--  
把完整的原代码和完整的报错贴出来看看
--  作者:cefobid2008
--  发布时间:4/13/2006 12:23:00 PM

--  
public class OWLParser {
static String inputFilename = "file:E://project/food.owl";
 public static void main(String[] args) {
  OntModel m = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
  m.read(inputFilename);
  Map nps = m.getNsPrefixMap();
  System.out.println(nps.toString());
  ExtendedIterator i1 = m.listClasses();
  while(i1.hasNext()){
   OntClass oc = (OntClass)i1.next();
   System.out.println("-------------------");
   System.out.println(oc.getLocalName());
    if(oc.getEquivalentClass()!=null){
   System.out.println("has <equivalentClass>"+oc.getEquivalentClass().getLocalName());
    }
  }

 }
}


--  作者:cefobid2008
--  发布时间:4/13/2006 12:26:00 PM

--  
<?xml version="1.0" ?>
  <!DOCTYPE owl (View Source for full doctype...)>
<rdf:RDF xmlns="http://www.example.org/food#" xmlns:food="http://www.example.org/food#" xmlns:vin="http://www.example.org/wine#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Class rdf:ID="Wine">
  <owl:equivalentClass rdf:resource="http://www.example.org/wine#Wine" />
  </owl:Class>
</rdf:RDF>

解析后报错:
Exception in thread "main" com.hp.hpl.jena.ontology.ConversionException: Cannot convert node http://www.example.org/wine#Wine to OntClass: it does not have rdf:type owl:Class or equivalent

谢了~


W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
46.875ms