我有一个描述http://purl.org/net/cnyt-literature简单本体的OWL文件。它有几个具有owl:sameAs
属性的实例,指的是DBpedia和Wikidata项。我想要做的是有一个联合SPARQL查询,用于从我的本体和DBpedia和Wikidata中描述的相关实体获取信息。
首先,我想使用SERVICE
或FROM
关键字在外部SPARQL端点(维基数据库或DBpedia)中查询我的本体。
其次,我想进行如上所述的联合查询。
我如何实现这些目标?
这是我的猫头鹰文件:
<?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>
更新:
以下是我尝试获取某些结果但未收到任何结果的查询(不是联合查询):
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}
我还尝试将?y
代替literature:writerOf
;仍然没有结果。