新书推介:《语义网技术体系》
作者:瞿裕忠,胡伟,程龚
   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讨论区 - Web新技术讨论『 Semantic Web(语义Web)/描述逻辑/本体 』 → 动态为owl新增instance 附程序 查看新帖用户列表

      发表一个新主题  发表一个新投票  回复主题  (订阅本版) 您是本帖的第 2744 个阅读者浏览上一篇主题  刷新本主题   树形显示贴子 浏览下一篇主题
     * 贴子主题: 动态为owl新增instance 附程序 举报  打印  推荐  IE收藏夹 
       本主题类别:     
     dasotkb 帅哥哟,离线,有人找我吗?
      
      
      等级:大二(研究C++)
      文章:62
      积分:278
      门派:XML.ORG.CN
      注册:2007/12/25

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给dasotkb发送一个短消息 把dasotkb加入好友 查看dasotkb的个人资料 搜索dasotkb在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看dasotkb的博客楼主
    发贴心情 动态为owl新增instance 附程序

    我的程序代码如下:
    OntModel m1 = ModelFactory.createOntologyModel();
    String NS="http://ontology/DMCLab#";   
          
           m1.getDocumentManager().addAltEntry( " http://ontology/DMCLab",
                                                     "file:D://Eclipse-SDK-3.2//Workspace//Agent//Domain_Knowledge_Repository//MusicOwl.owl" );
               
                 m1.read("http://ontology/DMCLab");

                 OntClass c = m1.getOntClass( NS + "singer" );


                 Individual ind_ns = m1.createIndividual( NS + "Jolin", c );
                
                String Genre=" http://ontology/DMCLab#hasGenre";
                String Year="http://ontology/DMCLab#hasYear";
                String Value=" http://ontology/DMCLab#hasSingerCountValue";
                  
                   Property arg1=m1.getProperty(Genre);
                   Property arg2=m1.getProperty(Year);
                   Property arg3=m1.getProperty(Value);
                   
                   m1.add(ind_ns, arg1, "pop");
                   m1.add(ind_ns, arg2, "2008");
                   m1.add(ind_ns, arg3, "99");
    PrintStream p;
     try {
     p = new PrintStream("D://Eclipse-SDK-3.2//Workspace//Agent//Domain_Knowledge_Repository//MIRAU01S01.owl");
      m1.write(p,"RDF/XML-ABBREV");
       p.close();


    输出owl新增instance的内容如下:
    <singer rdf:about="http://ontology/DMCLab#Jolin">
        <hasSingerCountValue>99</hasSingerCountValue>
        <hasYear>2008</hasYear>
        <hasGenre>pop</hasGenre>
      </singer>

    但我想要的内容是像下面的:

    <singer rdf:ID="Jolin">
        <hasSingerCountValue rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >99</hasSingerCountValue>
        <hasYear rdf:datatype="http://www.w3.org/2001/XMLSchema#int"
        >2008</hasType>
        <hasGenre rdf:datatype="http://www.w3.org/2001/XMLSchema#string"
        >pop</hasArea>
       </singer>

    问题:
    不知要如何写才可以将rdf:datatype= …. 那些东西输出到owl..请前辈指导一下.谢谢!!


       收藏   分享  
    顶(0)
      




    点击查看用户来源及管理<br>发贴IP:*.*.*.* 2008/7/3 16:20:00
     
     jpz6311whu 帅哥哟,离线,有人找我吗?
      
      
      
      威望:9
      等级:研三(收到微软亚洲研究院的Offer了)(版主)
      文章:1718
      积分:10610
      门派:W3CHINA.ORG
      注册:2005/4/12

    姓名:(无权查看)
    城市:(无权查看)
    院校:(无权查看)
    给jpz6311whu发送一个短消息 把jpz6311whu加入好友 查看jpz6311whu的个人资料 搜索jpz6311whu在『 Semantic Web(语义Web)/描述逻辑/本体 』的所有贴子 引用回复这个贴子 回复这个贴子 查看jpz6311whu的博客2
    发贴心情 
    com.hp.hpl.jena.rdf.model
    Interface Model


    createTypedLiteral
    Literal createTypedLiteral(java.lang.Object value,
                               RDFDatatype dtype)Build a typed literal from its value form.
    Note that in preview releases of Jena2 it was also possible to specify a language type. Changes to the RDF specification mean that this is no longer legal except for plain literals. To create a plain literal with a language tag use createLiteral.


    Parameters:
    value - the value of the literal
    dtype - the type of the literal, null for old style "plain" literals

    --------------------------------------------------------------------------------

    createTypedLiteral
    Literal createTypedLiteral(java.lang.Object value)Build a typed literal label from its value form using whatever datatype is currently registered as the the default representation for this java class. No language tag is supplied.

    Specified by:
    createTypedLiteral in interface ModelCon
    Parameters:
    value - the literal value to encapsulate
    Returns:
    a new literal representing the value v

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

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

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