以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  我快哭了,用jena如何获得individual的data property..........  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=64442)


--  作者:jack8375
--  发布时间:7/7/2008 6:15:00 PM

--  我快哭了,用jena如何获得individual的data property..........
我快哭了,用jena如何获得individual的data property..........
--  作者:jpz6311whu
--  发布时间:7/7/2008 7:59:00 PM

--  
楼主是要得到property还是property value?
--  作者:jack8375
--  发布时间:7/8/2008 9:20:00 AM

--  
我是想获取property value...jena中有啥方法可以获取得到呢?
--  作者:jpz6311whu
--  发布时间:7/10/2008 12:01:00 PM

--  
com.hp.hpl.jena.ontology
Interface OntResource

getPropertyValue
RDFNode getPropertyValue(Property property)Answer the value of a given RDF property for this resource, or null if it doesn't have one. The value is returned as an RDFNode, from which the concrete data value can be extracted for literals. If the value is a resource, it will present the OntResource facet. If there is more than one RDF statement with the given property for the current value, it is not defined which of the values will be returned.


Parameters:
property - An RDF property
Returns:
An RDFNode whose value is the value, or one of the values, of the given property. If the property is not defined the method returns null.


--  作者:retayi
--  发布时间:7/10/2008 3:20:00 PM

--  
可以问问高手 jpz6311whu 你那有没有关于Protege建模和jena调用的例子,我是新手,现在不知如何下手,谢谢
--  作者:jpz6311whu
--  发布时间:7/11/2008 2:15:00 PM

--  
ftp上有一些例子,楼主可以搜索一下论坛种类似的帖子,已经有很多人问这个问题了。
--  作者:jack8375
--  发布时间:7/13/2008 9:36:00 AM

--  
已解决,贴上代码大家分享:      
ExtendedIterator it = ontModel.listIndividuals();        
                     while(it.hasNext())
                     {
                           Individual oi = (Individual)it.next();
                           System.out.println("*********Individual:"+oi.getLocalName()+"*********");
                      
                           for (StmtIterator ipp = oi.listProperties(); ipp.hasNext();)
                           {                       
                              Property p=ipp.nextStatement().getPredicate();
                              String temp =  p.getLocalName();    
                              System.out.println(temp+ " : "+oi.getPropertyValue(p));                         
                                 /* Resource s= ipp.nextStatement().getResource() ;
                                  for (StmtIterator ipp1 = s.listProperties(); ipp1.hasNext();)
                                  {                 
                                    Property p=ipp1.nextStatement().getPredicate() ;
                                    System.out.println( " : "+oi.getPropertyValue(p));
                                  }*/                               
                           }
                      }

--  作者:lanbinger2001
--  发布时间:7/14/2008 9:34:00 AM

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