以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  jena具体怎么操作owl本体呢???能实现添加实例么?  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=123119)


--  作者:lhy07031
--  发布时间:1/6/2012 9:53:00 PM

--  jena具体怎么操作owl本体呢???能实现添加实例么?

rt   model.read()后,owl文件中的owl标签都变成了rdf三元组,有些信息还丢失了,添加一些实例后(Triple(Node.createURI) )用model.write()写出来,为什么protege加载不了生成的owl文件呢???而且生产的owl文件跟读进去的格式有些区别   望高人指点
部分代码如下:
  Model model = ModelFactory.createDefaultModel();
    InputStream is = FileManager.get().open("./myfile.owl");
    model.read(is, "", "RDF/XML");
    is.close();

    Oracle oracle = new Oracle(szJdbcURL, szUser, szPasswd);
    
    ModelOracleSem modelDest = ModelOracleSem.createOracleSemModel(oracle, szModelName);

    GraphOracleSem g = modelDest.getGraph();
    g.dropApplicationTableIndex();

    String tbs = "SYSAUX"; // can be customized    
    g.getBulkUpdateHandler().addInBulk(GraphUtil.findAll(model.getGraph()), tbs);
   
    g.add(Triple.create(Node.createURI("http://www.owl-ontologies.com/eventmodel.owl#Content_1"), Node.createURI("http://www.w3.org/1999/02/22-rdf-syntax-ns#type"), Node.createURI("http://www.owl-ontologies.com/eventmodel.owl#Content")));

     g.add(Triple.create(Node.createURI("http://www.owl-ontologies.com/eventmodel.owl#Content_1"), Node.createURI("http://www.owl-ontologies.com/eventmodel.owl#hasContent"), Node.createURI(\"这是内容\" "^^xsd:string")));
    
     g.rebuildApplicationTableIndex();
    
    OutputStream os = new FileOutputStream("./earthquakenews2.owl");
    modelDest.write(os,"RDF/XML");
    os.close();


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