新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   XML论坛     >>W3CHINA.ORG讨论区<<     计算机科学论坛     SOAChina论坛     Blog     开放翻译计划     新浪微博  
 
  • 首页
  • 登录
  • 注册
  • 软件下载
  • 资料下载
  • 核心成员
  • 帮助
  •   Add to Google

    >> 本版讨论Semantic Web(语义Web,语义网或语义万维网, Web 3.0)及相关理论,如:Ontology(本体,本体论), OWL(Web Ontology Langauge,Web本体语言), Description Logic(DL, 描述逻辑),RDFa,Ontology Engineering等。
    [返回] W3CHINA.ORG讨论区 - 语义网·描述逻辑·本体·RDF·OWLW3CHINA.ORG讨论区 - Web新技术讨论『 Semantic Web(语义Web)/描述逻辑/本体 』 → 本体中添加子类后jena中查询没结果 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 14738 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 本体中添加子类后jena中查询没结果 举报  打印  推荐  IE收藏夹 
       本主题类别: Ontology Engineering | RDF/RDFS    
     2010JLJ 美女呀,离线,快来找我吧!
      
      
      等级:大一(猛啃高等数学)
      文章:8
      积分:105
      门派:XML.ORG.CN
      注册:2011/3/11

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给2010JLJ发送一个短消息 把2010JLJ加入好友 查看2010JLJ的个人资料 搜索2010JLJ在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看2010JLJ的博客楼主
    发贴心情 本体中添加子类后jena中查询没结果

    public void test2(){
     OntModel student_ontModel1 = ModelFactory.createOntologyModel();
     OntDocumentManager dm1 = student_ontModel1.getDocumentManager();
     dm1.addAltEntry("http://www.owl-ontologies.com/OntologyStudent.owl", "file:"+"2011.9.5.rdf-xml.owl");
     student_ontModel1.read("file:D:/Program Files/Protege_3.4.5/2011.9.5.rdf-xml.owl");
     
     String prefix = "PREFIX owl:<http://www.w3.org/2002/07/owl#>"+
     "PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
     "PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>"+
     "PREFIX base:<http://www.owl-ontologies.com/OntologyStudent.owl#>";
     String select = "select ?sub ";
     String where = " where{?sub base:subClassOf base:Student"  +
       "}";//原来的本体中有Student类,其个体也可查   询,但是添加子类及子类的个体以后,这里就查不出来了,也没有错误提示,但在protege中直接用Sparql查询却可以得到想要的结果。请大家指点 Query query1=QueryFactory.create(prefix + select + where);
     QueryExecution qe1 = QueryExecutionFactory.create(query1, student_ontModel1);
     ResultSet results1 = qe1.execSelect();
     System.out.print(prefix+select+where+"\n");
        while(results1.hasNext()){
         QuerySolution qs = results1.nextSolution();
                    System.out.print(qs.get("sub").toString());
         System.out.print("\t");
         System.out.print("Student");
                    System.out.print("\n");
            }
        qe1.close();
    }

       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2011/9/14 15:20:00
     
     GoogleAdSense
      
      
      等级:大一新生
      文章:1
      积分:50
      门派:无门无派
      院校:未填写
      注册:2007-01-01
    给Google AdSense发送一个短消息 把Google AdSense加入好友 查看Google AdSense的个人资料 搜索Google AdSense在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 访问Google AdSense的主页 引用回复这个贴子 回复这个贴子 查看Google AdSense的博客广告
    2024/4/20 10:54:12

    本主题贴数1,分页: [1]

    管理选项修改tag | 锁定 | 解锁 | 提升 | 删除 | 移动 | 固顶 | 总固顶 | 奖励 | 惩罚 | 发布公告
    W3C Contributing Supporter! W 3 C h i n a ( since 2003 ) 旗 下 站 点
    苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
    78.125ms