0

I have an OWL file describing a simple ontology at http://purl.org/net/cnyt-literature. It has a couple of instances which have owl:sameAs property referring to DBpedia and Wikidata items. What I want to do is to have a federated SPARQL query for both obtaining information from my ontology and the related entities described in DBpedia and Wikidata.

First, I want to query my ontology in an external SPARQL endpoint (Wikidata or DBpedia), using SERVICE or FROM keywords.

Second, I want to make a federated query described as above.

How can I achieve these?

Here is my owl file :

<?xml version="1.0"?>
<rdf:RDF xmlns="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#"
 xml:base="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature"
 xmlns:literature="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
 xmlns:owl="http://www.w3.org/2002/07/owl#"
 xmlns:xml="http://www.w3.org/XML/1998/namespace"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature"/>
<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#character -->

<owl:ObjectProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#character">
    <rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play"/>
    <rdfs:range rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#writerOf -->

<owl:ObjectProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#writerOf">
    <rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer"/>
    <rdfs:range rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play"/>
</owl:ObjectProperty>

<!-- http://www.w3.org/2002/07/owl#sameAs -->
<owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#sameAs">
    <rdfs:domain rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
    <rdfs:range rdf:resource="http://www.w3.org/2002/07/owl#Thing"/>
</owl:ObjectProperty>
<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#name -->

<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#name">
    <rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
    <rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work"/>
    <rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician"/>
    <rdfs:domain rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer"/>
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
</owl:DatatypeProperty>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#uri -->

<owl:DatatypeProperty rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#uri"/>

<!-- http://www.w3.org/2002/07/owl#sameAs -->

<owl:DatatypeProperty rdf:about="http://www.w3.org/2002/07/owl#sameAs"/>
<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
 -->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem -->

<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human -->

<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work -->

<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work"/>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play -->

<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Literary_Work"/>
</owl:Class>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician -->

<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
</owl:Class>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer -->

<owl:Class rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer">
    <rdfs:subClassOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Human"/>
</owl:Class>
<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
 -->
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Politician"/>
    <character rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar"/>
    <owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/resource/Julius_Caesar</owl:sameAs>
    <owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</owl:sameAs>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_DbPedia -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_DbPedia">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
    <uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/page/Julius_Caesar</uri>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Play"/>
    <character rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar"/>
    <writerOf rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play"/>
    <owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/Julius_Caesar_(play)</owl:sameAs>
    <owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</owl:sameAs>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_DbPedia -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_DbPedia">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
    <uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">http://dbpedia.org/resource/Julius_Caesar_(play)</uri>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_Wikidata -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Play_Wikidata">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
    <uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q215750</uri>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Wikidata -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Julius_Caesar_Wikidata">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
    <uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q1048</uri>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#Writer"/>
    <owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/William_Shakespeare</owl:sameAs>
    <owl:sameAs rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</owl:sameAs>
</owl:NamedIndividual>
<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Dbpedia -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Dbpedia">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
    <uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">dbpedia.org/page/William_Shakespeare</uri>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Wikidata -->

<owl:NamedIndividual rdf:about="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#William_Shakespeare_Wikidata">
    <rdf:type rdf:resource="http://www.semanticweb.org/cnytync/ontologies/2017/6/literature#ExternalItem"/>
    <uri rdf:datatype="http://www.w3.org/2001/XMLSchema#string">https://www.wikidata.org/wiki/Q692</uri>
</owl:NamedIndividual>

UPDATE:

And here is the query (not a federated one) I tried for obtaining some results but received none:

PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX literature: <http://purl.org/net/cnyt-literature#>

select * from <http://purl.org/net/cnyt-literature> where {?x literature:writerOf ?z}

I also tried to put ?y instead of literature:writerOf; still no results.

TallTed
  • 9,069
  • 2
  • 22
  • 37
cuneyttyler
  • 1,255
  • 2
  • 17
  • 27
  • 1
    Well… You can't, quite. The DBpedia endpoint is configured to prevent federated queries against external endpoints. I believe the Wikidata endpoint is likewise. You could use the [URIBurner endpoint](http://linkeddata.uriburner.com/sparql/) for this after authenticating (as *anonymous* federation is blocked here, to help prevent abuse). For the rest… What have you tried? What's wrong with the results you got? – TallTed Jul 24 '17 at 16:01
  • Why can't you do it the other way around? Use a local triple store and query DBpedia via `SERVICE` sub-query? – UninformedUser Jul 24 '17 at 18:34
  • @TallTed I added the query I tried to the question which I expected to get some results but none – cuneyttyler Jul 24 '17 at 20:30
  • @AKSW Sure, I will try. – cuneyttyler Jul 24 '17 at 20:30
  • @AKSW But first, I need to figure out how to query an OWL file. – cuneyttyler Jul 24 '17 at 20:41
  • And this query does not even work in my local Jena server. Maybe the problem is with my OWL file. I created it with Protege and It is the first OWL file I generated. – cuneyttyler Jul 24 '17 at 20:51
  • Your OWL file isn't at the URL cited. That's an indirection, which currently points to a `sessionExpired` page. I think you will benefit by starting with simpler local-only basics, before you move to working with remote files and endpoints, and *then* think about federated queries. – TallTed Jul 24 '17 at 21:14
  • Ehm, where do you run the SPARQL query? If you use Protege, why do you need the `FROM` clause - that's not necessary? By the way, this also holds for others as long as you did not load it into a specific graph into the triple store. – UninformedUser Jul 25 '17 at 00:47
  • I ran it on http://linkeddata.uriburner.com/sparql and also on my local jena fuseki server and it returned no results. – cuneyttyler Jul 25 '17 at 07:09

0 Answers0