从来就这一个人在我的本体论:SPARQL查询返回0
<!-- http://127.0.0.1/Public_Contracting.owl#CPV1 -->
<owl:NamedIndividual rdf:about="&Public_Contracting;CPV1">
<rdf:type rdf:resource="&Public_Contracting;CPV"/>
<isCPVOf rdf:resource="&Public_Contracting;Procedure_1"/>
</owl:NamedIndividual>
<!-- http://127.0.0.1/Public_Contracting.owl#CPV2 -->
<owl:NamedIndividual rdf:about="&Public_Contracting;CPV2">
<rdf:type rdf:resource="&Public_Contracting;CPV"/>
<isCPVOf rdf:resource="&Public_Contracting;Procedure_2"/>
</owl:NamedIndividual>
<!-- http://127.0.0.1/Public_Contracting.owl#Procedure_1 -->
<owl:NamedIndividual rdf:about="&Public_Contracting;Procedure_1">
<rdf:type rdf:resource="&Public_Contracting;Procedure"/>
<hasCPV rdf:resource="&Public_Contracting;CPV1"/>
</owl:NamedIndividual>
<!-- http://127.0.0.1/Public_Contracting.owl#Procedure_2 -->
<owl:NamedIndividual rdf:about="&Public_Contracting;Procedure_2">
<rdf:type rdf:resource="&Public_Contracting;Procedure"/>
<hasCPV rdf:resource="&Public_Contracting;CPV2"/>
</owl:NamedIndividual>
而且我正尝试检索包含CPV1的所有程序。
我该如何用SPARQL做到这一点?
我尝试这样做:
PREFIX ns: <http://127.0.0.1/Public_Contracting.owl#>
SELECT ?proc
WHERE {
?proc a ns:Procedure ;
ns:hasCPV ?cpv.
?cpv ns:CPV ?cpvp
FILTER regex (?cpvp, "^CPV1")
}
但我没有得到任何结果。
这是我的本体论:
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY Public_Contracting "http://127.0.0.1/Public_Contracting.owl#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >]>
<rdf:RDF xmlns="http://127.0.0.1/Public_Contracting.owl#"
xml:base="http://127.0.0.1/Public_Contracting.owl"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:Public_Contracting="http://127.0.0.1/Public_Contracting.owl#"
xmlns:owl="http://www.w3.org/2002/07/owl#">
<owl:Ontology rdf:about="http://127.0.0.1/Public_Contracting.owl"/>
<!-- http://127.0.0.1/Public_Contracting.owl#Procedure -->
<owl:Class rdf:about="&Public_Contracting;Procedure">
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasSupplier"/>
<owl:someValuesFrom rdf:resource="&Public_Contracting;Supplier"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasBuyer"/>
<owl:onClass rdf:resource="&Public_Contracting;Buyer"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasProposal"/>
<owl:someValuesFrom rdf:resource="&Public_Contracting;Proposal"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasProcedureTeam"/>
<owl:onClass rdf:resource="&Public_Contracting;Procedure_Team"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasStatus"/>
<owl:onClass rdf:resource="&Public_Contracting;Procedure_Status"/>
<owl:qualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:qualifiedCardinality>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasAdjudicationCriterion"/>
<owl:someValuesFrom rdf:resource="&Public_Contracting;Adjudication_Criterion"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="&Public_Contracting;hasCPV"/>
<owl:someValuesFrom rdf:resource="&Public_Contracting;CPV"/>
</owl:Restriction>
</rdfs:subClassOf>
<owl:disjointWith rdf:resource="&Public_Contracting;Procedure_Team"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Proposal"/>
</owl:Class>
<!-- http://127.0.0.1/Public_Contracting.owl#CPV -->
<owl:Class rdf:about="&Public_Contracting;CPV">
<owl:disjointWith rdf:resource="&Public_Contracting;Candidature"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Clarifications"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Entity"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Person"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Procedure"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Procedure_Team"/>
<owl:disjointWith rdf:resource="&Public_Contracting;Proposal"/>
</owl:Class>
我想这是一个命名空间问题:在你的SPARQL查询中,一切都在命名空间''中。你确定在你的本体论中也是这样吗?例如在你有' '的本体片段中,但我不确定默认名称空间(用于hasCPV)是否是你期望的。 –
MarcoS
但问题在于过滤。如果我删除查询中的最后两个句子,我会公开:Procedure_1和public:Procedure_2。我无法过滤。有任何想法吗? –
我编辑了问题 –