2009-10-20 57 views
7

我希望有人能幫助我在這很可能完全易於解決的問題:SPARQL查詢給人意想不到的結果

我想請對下列RDF一個SPARQL查詢(在N3指出的那樣,RDF/XML坐鎮here)。這是一個期刊文章和期刊,作者的描述和出版商的desription:

@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:前的主頁: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 
} 

(再次:這是去是隻用於測試,因爲只有一個物品的實體),我的本地機器上PYT

運行它洪和RDflib沒有給我一個結果。在線Redland SPARQL查詢演示也不是。

誰在那裏看到解決方案?我在正確的道路上還是完全錯誤的?

回答

7

我不認爲你可以在XML屬性值中使用QName;例如值爲rdf:about。所以從您的RDF/XML文件考慮這一行:

<bibo:Journal rdf:about="ex:bibdienst"> 

我認爲這實際上是說,主題URI是「恩:bibdienst」。即語法上有效的URI,而是作爲對應於這條線的三重的對象出現是不相同的URI:

<dc:isPartOf rdf:resource="http://example.org/thesis/bibdienst" /> 

嘗試在XML取代的QName屬性值與相應的URI,看看是否修復你的問題。

+0

完美。這解決了我的問題。不知何故,我對XML和N3中允許的內容感到困惑,又不感謝:)再次感謝! – fab 2009-10-20 17:32:10

6

是的斯蒂芬·C是完全正確的,你不能在XML屬性的QName使用,您可以使用XML實體,而不是你在DTD塊在文檔的頂部定義,像這樣:

如。

<!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"> 
+0

感謝您的建議。我會嘗試一個(我確實總是想知道XML中的「&[prefix]」是什麼意思,多虧了你,現在我完全清楚了)。非常感謝! – fab 2009-10-20 17:33:35

相關問題