以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  [求助]有关jena的函数问题  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=61678)


--  作者:fanyi
--  发布时间:4/22/2008 3:31:00 PM

--  [求助]有关jena的函数问题
jena的函数addAltEntry和read的参数都代表什么? 请指教
--  作者:fanyi
--  发布时间:4/22/2008 7:14:00 PM

--  
怎么没人回答我啊?小弟有急用啊!拜托各位了!
--  作者:jpz6311whu
--  发布时间:4/22/2008 9:26:00 PM

--  
Controlling imports processing
To load an ontology without building the imports closure, call the method setProcessImports( false ) on the document manager object, or set the processImports property in the policy file. To be more selective, it is possible to ignore certain URI's when loading the imported documents. Call the method addIgnoreImport( String uri ) on the document manager object, or set the ignoreImport property in the policy.

A strength of working with ontologies is that we can reuse work done by other ontologists by importing their published ontologies. Often, however, this means that the ontology is only retrievable by traversing an Internet firewall. Even if this is possible, by using an HTTP proxy, it may impose unacceptable delay in loading an application. In the worst case, an ontology on which our application depends is temporarily or permanently unavailable from the original published URL. To assist with this common problem, the ontology document manager allows a local indirection, so that an attempt to import a document from a given published URL means that a local copy of the document is retrieved instead. This may be a file copy or simply duplicated on an internal mirror web site.

To specify this local redirection in the policy file, we use the following declarations:

<OntologySpec>
  <!-- local version of the RDFS vocabulary -->
  <publicURI rdf:resource="http://www.w3.org/2000/01/rdf-schema"    />
  <altURL rdf:resource="file:vocabularies/rdf-schema.rdf" />
  <language rdf:resource="http://www.w3.org/2000/01/rdf-schema" />
  <prefix rdf:datatype="&xsd;string">rdfs</prefix>
</OntologySpec>This specifies that an attempt to load the RDFS vocabulary from http://www.w3.org/2000/01/rdf-schema will transparently cause file:vocabularies/rdf-schema.rdf to be fetched instead. Any number of such re-directions may be specified in the policy file, or they can be added to the document manager object directly by calling the various 'add' methods (see the Javadoc for details). As a side-effect, this mechanism also means that ontologies can be named with any legal URI (not necessarily resolvable) - so long as the altURL is itself resolvable.


Example
In the following example, we programmatically declare that the camera ontology is copied locally, and then load it using the public URL. Assume that the constant JENA has been initialized to the directory in which Jena is installed.

OntModel m = ModelFactory.createOntologyModel();
OntDocumentManager dm = m.getDocumentManager();
dm.addAltEntry( "http://www.xfront.com/owl/ontologies/camera/",
                "file:" + JENA + "src-examples/data/camera.owl"    );
m.read( "http://www.xfront.com/owl/ontologies/camera/" );


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