[英]SPARQL Query gives unexpected result
我希望有人可以帮助我解决这个问题,这个问题可能很容易解决:
我想针对以下RDF运行SPARQL查询(在N3中注明,RDF / XMl位于此处 )。 这是期刊文章的描述以及期刊,作者和出版商的描述:
@prefix bibo: <http://purl.org/ontology/bibo/> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix ex: <http://example.org/thesis/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<ex:XY> a bibo:Article;
dc:creator ex:umstaetter;
dc:date "2008-11-01";
dc:isPartOf ex:bibdienst;
dc:title "DDC in Europa"@de;
bibo:endPage "1221";
bibo:issue "11";
bibo:language "de";
bibo:pageStart "1194";
bibo:uri <http://www.zlb.de/Erschliessung020309BD.pdf>;
bibo:volume "42" .
<ex:bibdienst> a bibo:Journal;
dc:publisher ex:zlb;
dc:title "Bibliotheksdienst"@de;
bibo:issn "00061972" .
<ex:umstaetter> a foaf:person;
foaf:birthday "1941-06-12";
foaf:gender "Male";
foaf:givenName "Walther";
foaf:homepage <http://www.ib.hu-berlin.de/~wumsta/index.html>;
foaf:img "http://libreas.eu/ausgabe7/pictures/wumstaetter1.jpg";
foaf:name "Walther Umst\u00E4tter";
foaf:surname "Umst\u00E4tter";
foaf:title "Prof. Dr. rer. nat." .
<ex:zlb> a foaf:Organization;
foaf:homepage <http://www.zlb.de>;
foaf:name "Zentral- und Landesbibliothek Berlin"@de .
出于测试目的,我想读出foaf: ex:zlb的 主页 - 我想要运行的SPARQL是:
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dc: <http://purl.org/dc/elements/1.1/>
PREFIX bibo: <http://purl.org/ontology/bibo/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ex: <http://example.org/thesis/>
SELECT ?article ?publisher ?publisher_url
WHERE
{
?article dc:isPartOf ?journal .
?journal dc:publisher ?publisher .
?publisher foaf:homepage ?publisher_url
}
(再说一遍:这只是为了测试,因为文章只有一个实体。)
使用Python和RDflib在我的本地机器上运行它不会给我一个结果。 在线Redland SPARQL查询演示也没有。
谁有人看到解决方案? 我是在正确的道路上还是完全错了?
我认为你不能在XML属性值中使用QName; 例如rdf:about
的值。 所以请考虑RDF / XML文件中的这一行:
<bibo:Journal rdf:about="ex:bibdienst">
我认为这实际上是说主题URI是“ex:bibdienst”。 这是一个语法上有效的URI,但它与对应于此行的三元组的对象所显示的URI不同:
<dc:isPartOf rdf:resource="http://example.org/thesis/bibdienst" />
尝试使用相应的URI替换XML属性值中的QNames,看看是否能解决您的问题。
是的Stephen C完全正确,你不能在XML属性中使用QNames,你可以使用你在文档顶部的DTD块中定义的XML实体,如下所示:
例如。
<!DOCTYPE rdf:RDF[
<!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'>
<!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'>
<!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'>
<!ENTITY ex 'http://example.org/thesis/'>
<!ENTITY dc 'http://purl.org/dc/elements/1.1/'>
<!ENTITY foaf 'http://xmlns.com/foaf/0.1/'>
<!ENTITY bibo 'http://purl.org/ontology/bibo/'>
]>
然后你可以像这样定义属性:
<bibo:Journal rdf:about="&ex;bibdienst">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.