新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   >>中国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等。
    [返回] 中文XML论坛 - 专业的XML技术讨论区W3CHINA.ORG讨论区 - Web新技术讨论『 Semantic Web(语义Web)/描述逻辑/本体 』 → 用sparql查询owl出现乱码 怎么办啊? 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 11793 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 用sparql查询owl出现乱码 怎么办啊? 举报  打印  推荐  IE收藏夹 
       本主题类别: Ontology Language | RDF/RDFS | XML文档存取技术(DOM, SAX)    
     kkllyao 帅哥哟,离线,有人找我吗?天蝎座1986-11-5
      
      
      等级:大一新生
      文章:2
      积分:57
      门派:XML.ORG.CN
      注册:2008/12/28

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给kkllyao发送一个短消息 把kkllyao加入好友 查看kkllyao的个人资料 搜索kkllyao在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看kkllyao的博客楼主
    发贴心情 用sparql查询owl出现乱码 怎么办啊?

    代码我是参考网上的:
    Model model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM, null );
    model.read("file:./xuexiao.owl"); // null base URI, since model URIs are absolute


    // Create a new query
    String queryString =
     "prefix rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
                     prefix rdfs:<http://www.w3.org/2000/01/rdf-schema#>
                     SELECT ?subject ?object
                     WHERE { ?subject rdfs:subClassOf ?object }";

    Query query = QueryFactory.create(queryString);

    // Execute the query and obtain results
    QueryExecution qe = QueryExecutionFactory.create(query, model);
    ResultSet results = qe.execSelect();

    // Output query results 
    ResultSetFormatter.out(System.out, results, query);

    // Important - free up resources used running the query
    qe.close();

    ------------------------------------结果---------------------------------------------------------------------
    -----------------------------------------------------------------------------------------------------------------------------------
    | subject                                                          | object                                                       |
    ===================================================================================================================================
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Professor> | <http://www.owl-ontologies.com/Ontology1229688475.owl#Staff> |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Assistant> | <http://www.owl-ontologies.com/Ontology1229688475.owl#Staff> |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Class>     | <http://www.owl-ontologies.com/Ontology1229688475.owl#teach> |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Staff>     | <http://www.owl-ontologies.com/Ontology1229688475.owl#teach> |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Course>    | <http://www.owl-ontologies.com/Ontology1229688475.owl#teach> |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Course>    | _:b0                                                         |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Course>    | _:b1                                                         |
    ----------------------------------------------------------------------------------------------------------------------
    owl是:
    <?xml version="1.0"?>
    <rdf:RDF
        xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
        xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
        xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
        xmlns:owl="http://www.w3.org/2002/07/owl#"
        xmlns="http://www.owl-ontologies.com/Ontology1229688475.owl#"
      xml:base="http://www.owl-ontologies.com/Ontology1229688475.owl">
      <owl:Ontology rdf:about=""/>
      <owl:Class rdf:ID="Course">
        <rdfs:subClassOf>
          <owl:Restriction>
            <owl:allValuesFrom>
              <owl:Class rdf:ID="Class"/>
            </owl:allValuesFrom>
            <owl:onProperty>
              <owl:ObjectProperty rdf:ID="is_taught_on"/>
            </owl:onProperty>
          </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
          <owl:Restriction>
            <owl:allValuesFrom>
              <owl:Class rdf:ID="Professor"/>
            </owl:allValuesFrom>
            <owl:onProperty>
              <owl:ObjectProperty rdf:ID="is_taught_by"/>
            </owl:onProperty>
          </owl:Restriction>
        </rdfs:subClassOf>
        <rdfs:subClassOf>
          <owl:Class rdf:ID="teach"/>
        </rdfs:subClassOf>
      </owl:Class>
      <owl:Class rdf:ID="Staff">
        <rdfs:subClassOf rdf:resource="#teach"/>
      </owl:Class>
      <owl:Class rdf:about="#Class">
        <rdfs:subClassOf rdf:resource="#teach"/>
      </owl:Class>
      <owl:Class rdf:ID="Assistant">
        <rdfs:subClassOf rdf:resource="#Staff"/>
      </owl:Class>
      <owl:Class rdf:about="#Professor">
        <rdfs:subClassOf rdf:resource="#Staff"/>
      </owl:Class>
      <owl:ObjectProperty rdf:ID="manage">
        <rdfs:domain rdf:resource="#Assistant"/>
        <rdfs:range rdf:resource="#Class"/>
      </owl:ObjectProperty>
      <Course rdf:ID="Course_AI">
        <is_taught_by>
          <Professor rdf:ID="Professor_Wang"/>
        </is_taught_by>
        <is_taught_on>
          <Class rdf:ID="Class_00"/>
        </is_taught_on>
      </Course>
      <Class rdf:ID="Class_01"/>
      <Course rdf:ID="Course_DKK">
        <is_taught_by rdf:resource="#Professor_Wang"/>
        <is_taught_on rdf:resource="#Class_01"/>
      </Course>
      <Course rdf:ID="Course_DB">
        <is_taught_by>
          <Professor rdf:ID="Professor_Zhao"/>
        </is_taught_by>
        <is_taught_on rdf:resource="#Class_01"/>
      </Course>
      <Class rdf:ID="Class_02"/>
      <Assistant rdf:ID="Assistant_Li">
        <manage rdf:resource="#Class_02"/>
      </Assistant>
    </rdf:RDF>

    <!-- Created with Protege (with OWL Plugin 3.3.1, Build 430)  http://protege.stanford.edu -->

    --------------------------------------------
    问题是最后两行应该是:| <http://www.owl-ontologies.com/Ontology1229688475.owl#Course>    | is_taught_on only Class                                                        |
    | <http://www.owl-ontologies.com/Ontology1229688475.owl#Course>    | is_taught_by only Professor                                                  |


    这个结果是在protege里面得到的。。但是为什么在这个算法里面就乱码了。。
    各位帮忙看一下。谢谢。。

          

    [此贴子已经被作者于2008-12-29 10:10:29编辑过]

       收藏   分享  
    顶(0)
      




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

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

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