新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   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)/描述逻辑/本体 』 → 关于sparql查询的问题 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 9731 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 关于sparql查询的问题 举报  打印  推荐  IE收藏夹 
       本主题类别: Ontology Language | RDF/RDFS    
     ehuangjiazi 美女呀,离线,快来找我吧!
      
      
      等级:大一(高数修炼中)
      文章:32
      积分:164
      门派:XML.ORG.CN
      注册:2010/11/23

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给ehuangjiazi发送一个短消息 把ehuangjiazi加入好友 查看ehuangjiazi的个人资料 搜索ehuangjiazi在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看ehuangjiazi的博客楼主
    发贴心情 关于sparql查询的问题


    把代码改了一下
    import com.hp.hpl.jena.rdf.model.*;
    import com.hp.hpl.jena.query.Query;
    import com.hp.hpl.jena.query.QueryExecution;
    import com.hp.hpl.jena.query.QueryExecutionFactory;
    import com.hp.hpl.jena.query.QueryFactory;
    import com.hp.hpl.jena.query.ResultSet;
    import com.hp.hpl.jena.query.ResultSetFormatter;
    import com.hp.hpl.jena.ontology.*;
    import com.hp.hpl.jena.reasoner.*;
    public class Animal{
      public static void main(String[] args) {
        OntModel text_ontmodel = ModelFactory.createOntologyModel();
           OntDocumentManager dm = text_ontmodel.getDocumentManager();
           dm.addAltEntry("http://www.owl-ontologies.com/Ontology1299637864.owl#","file:" + "Animal.owl");
           text_ontmodel.read("file:E:/Program Files/Protege_3.4.4/Animal.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 xsd:<http://www.w3.org/2001/XMLSchema#string>"+
                        "PREFIX eg:<http://www.owl-ontologies.com/Carnivore.owl#>"
                        ;
           String slect =  "SELECT ?x ";
           String where =   "WHERE {"+
           "?x rdfs:subClassOf eg:Carnivore"+
           "}";

           Query query = QueryFactory.create(prefix + slect + where);
           Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
           InfModel inf = ModelFactory.createInfModel(reasoner, text_ontmodel);
           QueryExecution qe = QueryExecutionFactory.create(query,inf);
           ResultSet results = qe.execSelect();
           ResultSetFormatter.out(System.out,results,query);
           qe.close();
      }
    }
    然后显示的是


    -----
    | x |
    =====
    -----



    我想问一下,为什么出来的不是Carnivore类下面的子类呢?只显示字段名称。。

    还有一个问题想问一下,就是可以附加图吗?就是在owl文件里面可以有图吗?查询的时候可以查出来的。


       收藏   分享  
    顶(0)
      




    ----------------------------------------------
    加油啊~~鸭梨好大~~~~~~

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

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

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