以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 Semantic Web(语义Web)/描述逻辑/本体 』  (http://bbs.xml.org.cn/list.asp?boardid=2)
----  关于sparql的错误  (http://bbs.xml.org.cn/dispbbs.asp?boardid=2&rootid=&id=90410)


--  作者:ehuangjiazi
--  发布时间:4/15/2011 5:21:00 PM

--  关于sparql的错误
以下是根据网上一些代码编写的,但是运行总出错,是什么原因呢?各位高手帮忙看一下?
public class New3{
  public static void main(String[] args) {
    OntModel text_ontmodel = ModelFactory.createOntologyModel();
       OntDocumentManager dm = text_ontmodel.getDocumentManager();
       dm.addAltEntry("http://www.owl-ontologies.com/Ontology1302774842.owl#","file:" + "animal2.owl");
       text_ontmodel.read("file:E:/Program Files/Protege_3.4.4/animal2.owl");
       String prefix = "PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
                       "PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
                    "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> " +
                    "PREFIX xsd:<http://www.w3.org/2001/XMLSchema#>"+
                    "PREFIX eg:<http://www.owl-ontologies.com/Ontology1302774842.owl#>"
                    ;
       String slect =  "SELECT ?name ?adress " ;
       String where =   "WHERE {"+
       
       "?name rdf:type eg:Zoo ."+
       "?name eg:adress ?adress ."+
       "}";


       Query query = QueryFactory.create(prefix + slect + where);
       Reasoner reasoner = ReasonerRegistry.getOWLReasoner();
       InfModel inf = ModelFactory.createInfModel(reasoner, text_ontmodel);
       QueryExecution qe = QueryExecutionFactory.create(query,inf);
       ResultSet results = qe.execSelect();
       ResultSetFormatter.out(System.out,results,query);
       qe.close();
  }
}

错误提示

Exception in thread "main" java.lang.ExceptionInInitializerError
 at com.hp.hpl.jena.graph.Node_URI.getLocalName(Node_URI.java:61)
 at com.hp.hpl.jena.rdf.model.impl.ResourceImpl.getLocalName(ResourceImpl.java:147)
 at com.hp.hpl.jena.rdf.model.impl.PropertyImpl.checkLocalName(PropertyImpl.java:55)
 at com.hp.hpl.jena.rdf.model.impl.PropertyImpl.<init>(PropertyImpl.java:66)
 at com.hp.hpl.jena.rdf.arp.test.WGTestSuite.<clinit>(WGTestSuite.java:165)
 at com.hp.hpl.jena.rdf.arp.test.ARPTests.suite(ARPTests.java:69)
 at com.hp.hpl.jena.rdf.arp.test.ARPTests.main(ARPTests.java:118)
Caused by: java.util.regex.PatternSyntaxException: Dangling meta character '?' near index 20
<|>|&|[


--  作者:ehuangjiazi
--  发布时间:4/15/2011 5:30:00 PM

--  
检查了一下owl文件,发现是查询条件要把eg:adress 改成eg:Adress ,但是结果还是不太对
----------------------------------------------------------
| name            | Address                              |
==========================================================
| eg:Tianjin_Zoo  | ""^^xsd:string                       |
| eg:Beijing_Zoo  | "Beijing Xizhimen Road"^^xsd:string  |
| eg:Shanghai_Zoo | "Shanghai Xizhimen Road"^^xsd:string |
----------------------------------------------------------

为什么第一行没有内容呢?


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