以文本方式查看主题

-  中文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=121453)


--  作者:licmi
--  发布时间:9/12/2011 12:23:00 AM

--  [求助]含传递参数的SPARQL查询
环境:Protege3.2.1+MySQL5.5+MyEclipse8.6+Jena2.6.4+ARQ2.8.7+Tomcat6.0.30+IE7+JSP
SPARQL查询语句:
QString =
"PREFIX lsrs:<http://www.owl-ontologies.com/Ontology1311044743.owl#>" +
"SELECT ?name ?auther ?knowledge ?abstract ?magazine ?year ?vol ?number " +
"WHERE {" +
"?auther lsrs:发表 ?paper." +
"?paper lsrs:论文名 ?name." +
"?paper lsrs:所属学科 ?knowledge." +
"?paper lsrs:摘要 ?abstract." +
"?paper lsrs:出版期刊 ?magazine." +
"?paper lsrs:发表年份 ?year." +
"?paper lsrs:期数 ?vol." +
"?paper lsrs:分类号 ?number." +
"?auther lsrs:姓名" + v_value +
".FILTER (?year > " + FLD_DAT_BEG + " || ?year < " + FLD_DAT_END + ")}";

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: An exception occurred processing JSP page /result.jsp at line 111

108: "}";
109: }
110:
111: Query query = QueryFactory.create(QString);
112: QueryExecution qe = QueryExecutionFactory.create(query,infModel);
113: ResultSet result = qe.execSelect();
114:


Stacktrace:
 org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:519)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:428)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

com.hp.hpl.jena.query.QueryParseException: Encountered " ">" "> "" at line 1, column 370.
Was expecting one of:
    <IRIref> ...
    <PNAME_NS> ...
    <PNAME_LN> ...
    <BLANK_NODE_LABEL> ...
    <VAR1> ...
    <VAR2> ...
    "true" ...
    "false" ...
    <INTEGER> ...
    <DECIMAL> ...
    <DOUBLE> ...
    <INTEGER_POSITIVE> ...
    <DECIMAL_POSITIVE> ...
    <DOUBLE_POSITIVE> ...
    <INTEGER_NEGATIVE> ...
    <DECIMAL_NEGATIVE> ...
    <DOUBLE_NEGATIVE> ...
    <STRING_LITERAL1> ...
    <STRING_LITERAL2> ...
    <STRING_LITERAL_LONG1> ...
    <STRING_LITERAL_LONG2> ...
    "(" ...
    ")" ...
    <NIL> ...
    "[" ...
    <ANON> ...
    
 com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:87)
 com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse(ParserSPARQL11.java:40)
 com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:132)
 com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:69)
 com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
 com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:28)
 org.apache.jsp.result_jsp._jspService(result_jsp.java:174)
 org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:386)
 org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
 org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
 javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


note The full stack trace of the root cause is available in the Apache Tomcat/6.0.30 logs.

v_value(String)、FLD_DAT_BEG(int)、 FLD_DAT_END(END)是上一个JSP页面提交的参数,Debug后可以确定已经成功传递进来。
设计本体时,类、属性、实例用的是中文,但是MySQL中没乱码,会影响查询么?


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