我想爲我的測試服務器構建正確的查詢,並且遇到了我無法定義PREFIX的問題。OpenRDF芝麻:無法定義前綴
例如,這個查詢的工作:
select * where
{
?stayingURL <http://localhost/resource_lng> ?lng .
?stayingURL <http://localhost/resource_staying_date> ?date .
?stayingURL <http://localhost/resource_address> ?address .
}
LIMIT 100
我嘗試按日期添加過濾器,就像這樣:
select * where
{
?stayingURL <http://localhost/resource_lng> ?lng .
?stayingURL <http://localhost/resource_staying_date> ?date .
?stayingURL <http://localhost/resource_address> ?address .
FILTER (?date > "2012-01-01"^^xsd:date)
}
LIMIT 100
現在我得到了以下錯誤: 「MALFORMED QUERY: org.openrdf.query.parser.sparql.ast.VisitorException: QName 'xsd:date' uses an undefined prefix
」
好的,我嘗試通過將以下行添加到查詢的開頭來手動聲明此前綴:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
現在,我得到這個錯誤:
MALFORMED QUERY: Encountered " "<" "< "" at line 1, column 14.
Was expecting:
<Q_IRI_REF> ...
這對我來說很陌生,但無論如何,我試圖把它直接寫,沒有任何前綴:
select * where
{
?stayingURL <http://localhost/resource_lng> ?lng .
?stayingURL <http://localhost/resource_staying_date> ?date .
?stayingURL <http://localhost/resource_address> ?address .
FILTER (?date > "2012-01-01"^^<http://www.w3.org/2001/XMLSchema#date>)
}
LIMIT 100
結果幾乎是一樣的:
MALFORMED QUERY: Encountered " "<" "< "" at line 1, column 228.
Was expecting one of:
<Q_IRI_REF> ...
<PNAME_NS> ...
<PNAME_LN> ...
我在做什麼錯?
這是我的服務器地址:http://176.34.226.101:8080/openrdf-sesame/repositories/ecomobile。
你如何將查詢發送到你的服務器?第二個查詢引用「第1行第228列」中的錯誤的事實表明您將它編碼爲HTTP請求中的參數。您確定在此請求中正確編碼了「<" and ">」字符嗎? – Jan 2012-03-15 19:19:53
@Jan,謝謝,這個問題真的是在網址編碼;但我想知道爲什麼第一個查詢的作品?它也包含'<' '>'字符。 – 2012-03-16 04:35:15