开发者

Doesn't understand SERQL queries

开发者 https://www.devze.com 2023-01-28 02:18 出处:网络
i set up a Sesame (openrdf.org) server and try to access it by the Java API. For test purpose I have used a really simple example from Wikipedia:

i set up a Sesame (openrdf.org) server and try to access it by the Java API.

For test purpose I have used a really simple example from Wikipedia:

<?xml version="1.0" encoding="UTF-8" ?>
  <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
     xmlns:dc="http://purl.org/dc/elements/1.1/">
  <rdf:Description rdf:about="http://de.wikipedia.org/wiki/Resource_Description_Framework">
 <dc:title>Resource Description Framework</dc:title>
 <dc:publisher>Wikipedia - Die freie Enzyklopädie</dc:publisher>
</rdf:Description>
</rdf:RDF> 

and

<?xml version="1.0" encoding="UTF-8" ?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/">
  <rdf:Description rdf:about="http://de.wikipedia.org/wiki/Resource_Description_Framework">
    <dc:title>Resource Description Framework 2</dc:title>
    <dc:publisher>Wikipedia - Die freie Enzyklopädie</dc:publisher>
  </rdf:Description>
</rdf:RDF>开发者_Go百科

The SPARQL query at the Sesame workbench works as expected:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?title
WHERE{
?res dc:publisher ?pub .
?res dc:title ?title

FILTER (
sameTerm(?pub, "Wikipedia - Die freie Enzyklopädie")
)
}

returns all title from the publisher "Wikipedia - Die freie Enzyklopädie".

Now for the Java API I try to translate this example into SERQL.

I tried following query:

SELECT title 
FROM {title} dc:publisher {"Wikipedia - Die freie Enzyklopädie"}
USING NAMESPACE
rdf = <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
dc = <http://purl.org/dc/elements/1.1/>

But this returns all data and not the title but the URL from rdf:about. I also tried different variations like "dc:title" instead of "title" but than I get no result at all.

I have already searched the net and read a lot of documentation. But somehow I don't really get the SERQL syntax.

Do you have some pointer for me? How do I get all title from a specific publisher as a result?

Thanks a lot!


First of all, there's a complete SeRQL manual available in the Sesame user documentation, so that should help you understand SeRQL's syntax.

As for your specific query, the problem is that your SeRQL query asks something different from the SPARQL query you gave earlier. I won't go into too much detail here, but the SeRQL-equivalent of your SPARQL query would be:

SELECT title 
FROM {res} dc:publisher {"Wikipedia - Die freie Enzyklopädie"}; 
           dc:title {title}
USING NAMESPACE
rdf = <http://www.w3.org/1999/02/22-rdf-syntax-ns#>,
dc = <http://purl.org/dc/elements/1.1/>

SeRQL represents triple-patterns in the form {subject} predicate {object} .

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号