以文本方式查看主题

-  计算机科学论坛  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  用jena创建了个本体,没有发现有xmlns前缀和xml:base前缀,有xmlns:base??  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=36466)


--  作者:seaheartgulinlin
--  发布时间:8/6/2006 10:43:00 AM

--  用jena创建了个本体,没有发现有xmlns前缀和xml:base前缀,有xmlns:base??
我使用jena创建了个本体,并保存到owl文件中,打开该文件却发现NAMESPACE不太对,如下:
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:base="http://www.edu.cn/jianyankm#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns:daml="http://www.daml.org/2001/03/daml+oil#">

没有发现有xmlns前缀和xml:base,怎么回事啊,请大侠们指教。多谢!
代码太长,主要是在程序中自动产生一个OntModel,并保存到数据库中,涉及到NsPrefix仅有以下代码片段:
ModelMaker maker = po.getRDBMaker(SharingVar.DB_URL, SharingVar.DB_USER,
                                      SharingVar.DB_PASSWD, SharingVar.DB, false);
    OntModel owlmodel = po.loadDB(maker, s_source);
    owlmodel.setNsPrefix("base", s_source);

其中s_source ="http://www.edu.cn/jianyankm#"

//*************************
public OntModel loadDB( ModelMaker maker, String source ) {
      // use the model maker to get the base model as a persistent model
      // strict=false, so we get an existing model by that name if it exists
      // or create a new one
      Model base = maker.createModel( source, false );

      // now we plug that base model into an ontology model that also uses
      // the given model maker to create storage for imported models
      OntModel m = ModelFactory.createOntologyModel( getModelSpec( maker ), base );

      // now load the source document, which will also load any imports
      //m.read( source );
      return m;
  }
//****************************************************
public ModelMaker getRDBMaker( String dbURL, String dbUser, String dbPw, String dbType, boolean cleanDB ) {
      try {
          // Create database connection
          IDBConnection conn  = new DBConnection( dbURL, dbUser, dbPw, dbType );
          Connection heicon = conn.getConnection();
          heicon.setAutoCommit(true);

          IRDBDriver mydriver =conn.getDriver();

          //conn.setAutoCommit(false);
          // do we need to clean the database?
          if (cleanDB) {
              //DriverRDB.unlockDB();
               //mydriver.unlockDB();
              conn.cleanDB();
          }

          // Create a model maker object
          return ModelFactory.createModelRDBMaker( conn );
      }
      catch (Exception e) {
          e.printStackTrace();
          System.exit( 1 );
      }

      return null;
  }

[此贴子已经被作者于2006-8-8 17:13:15编辑过]

--  作者:jpz6311whu
--  发布时间:8/8/2006 12:28:00 PM

--  
请楼主把程序代码贴出来看看
--  作者:MerryZhang
--  发布时间:8/8/2006 4:40:00 PM

--  
是的,没有程序无法判断错在哪里。
--  作者:lqm
--  发布时间:8/13/2006 11:05:00 AM

--  请教楼主:
楼主一定对Jena接口很熟悉,我请问楼主一个问题,关于用SPARQL查询RDF和OWL。已经发了求助帖子,请l楼主看看
谢谢!
--  作者:imagineer
--  发布时间:8/14/2006 10:55:00 AM

--  
空的xmlns前缀,以及xml:base并不是本体里面必须的两个头部声明吧~~~~~

另外xmlns:base我觉得只是简单的定义了一个叫base的名字空间,和前面两个概念没有任何联系


--  作者:jpz6311whu
--  发布时间:8/14/2006 5:20:00 PM

--  
在base参数中设置:
read
Model read(java.io.InputStream in,
           java.lang.String base,
           java.lang.String lang)

write
Model write(java.io.OutputStream out,
            java.lang.String lang,
            java.lang.String base)Write a serialized represention of a model in a specified language.

The language in which to write the model is specified by the lang argument. Predefined values are "RDF/XML", "RDF/XML-ABBREV", "N-TRIPLE" and "N3". The default value, represented by null, is "RDF/XML".


Parameters:
out - The output stream to which the RDF is written
base - The base uri to use when writing relative URI's. null means use only absolute URI's.
lang - The language in which the RDF should be written
Returns:
This model


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