views:

264

answers:

2

Hi to you all (and thanks for this great website since there doesn't seem to exist a forum on beginner-SPARQL-questions),

i hope someone can help me on this probably totally easy-to-solve problem: I want to run a SPARQL query against the following RDF (noted in N3, the RDF/XMl sits here). This is the desription of a journal article and descriptions of the journal, author and publisher:

 @prefix bibo: <http://purl.org/ontology/bibo/&gt; .
 @prefix dc: <http://purl.org/dc/elements/1.1/&gt; .
 @prefix ex: <http://example.org/thesis/&gt; .
 @prefix foaf: <http://xmlns.com/foaf/0.1/&gt; .
 @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt; .

<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&gt;;
     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&gt;;
     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&gt;;
     foaf:name "Zentral- und Landesbibliothek Berlin"@de .

For testing purposes I wanted to read out the foaf:homepage of ex:zlb - the SPARQL I want to run is:

PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;
PREFIX dc: <http://purl.org/dc/elements/1.1/&gt;
PREFIX bibo: <http://purl.org/ontology/bibo/&gt;
PREFIX foaf: <http://xmlns.com/foaf/0.1/&gt;
PREFIX ex: <http://example.org/thesis/&gt;

SELECT ?article ?publisher ?publisher_url
WHERE 
{
    ?article dc:isPartOf ?journal .
    ?journal dc:publisher ?publisher .
    ?publisher foaf:homepage ?publisher_url
}

(Again: This is gonna be for testing only since there is only one entity of article.)

Running it on my local machine with Python and RDflib doesn't give me a result. Neither does the Online Redland SPARQL Query Demo.

Anyone out there who sees a solution? Am I on the right path or totally wrong?

Thanks a million in advance and all the best from Berlin! fabian

+3  A: 

I don't think that you can use a QName in an XML attribute value; e.g. the value of rdf:about. So consider this line from your RDF/XML file:

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

I think that this is actually saying that the subject URI is "ex:bibdienst". That is a syntactically valid URI, but it is not the same URI as appears as the object of the triple corresponding to this line:

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

Try replacing the QNames in XML attribute values with the corresponding URIs and see if that fixes your problem.

Stephen C
Perfect. That fixed my problem. Somehow I got confused about what is allowed in XML and N3 and what not :) THANKS AGAIN!
fab
+2  A: 

Yep Stephen C is totally correct that you can't use QNames in XML attributes, you can use XML entities instead which you define in a DTD block at the top of your document like so:

eg.

<!DOCTYPE rdf:RDF[
    <!ENTITY rdf 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'&gt;
    <!ENTITY rdfs 'http://www.w3.org/2000/01/rdf-schema#'&gt;
    <!ENTITY xsd 'http://www.w3.org/2001/XMLSchema#'&gt;
    <!ENTITY ex 'http://example.org/thesis/'&gt;
    <!ENTITY dc 'http://purl.org/dc/elements/1.1/'&gt;
    <!ENTITY foaf 'http://xmlns.com/foaf/0.1/'&gt;
    <!ENTITY bibo 'http://purl.org/ontology/bibo/'&gt;
]>

Then you can define attributes like so:

<bibo:Journal rdf:about="&ex;bibdienst">
RobV
THANKS for the suggestion. I'll try that one out (I indeed always wondered what the "" in XML meant. thanks to you it's now totally clear to me). THANKS A LOT!
fab