此查询不返回任何内容。
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://test.com/my-ontology.owl#>
SELECT DISTINCT ?class ?birthyear ?gender
WHERE {
?class a owl:UserProfile.
OPTIONAL { ?class owl:birthyear ?birthyear}
OPTIONAL { ?class owl:gender ?gender}
}
LIMIT 25
但是,如果我放弃
?class a owl:UserProfile.
,此查询返回正确的结果:
class birthyear gender
owl:userProf_ES 1984 male
我也尝试过此查询,但它也返回空结果:
SELECT DISTINCT ?class ?type ?birthyear ?gender
WHERE {
?class rdf:type ?type.
?type rdfs:subClassOf owl:User.
OPTIONAL { ?class owl:birthyear ?birthyear}
OPTIONAL { ?class owl:gender ?gender}
}
LIMIT 25
为什么会这样?
UserProfile
是
User
. 我还有以下属性
用户配置文件
在保护中:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.test.com/my-ontology.owl#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX oo: <http://www.w3.org/2002/07/owl#>
INSERT {
owl:userProf_ES owl:name 'Roger' .
owl:userProf_ES owl:nationalityCode 'ES' .
owl:userProf_ES owl:languageCode 'es_ES' .
owl:userProf_ES owl:gender 'male' .
owl:userProf_ES owl:birthyear 1984 .
owl:userProf_ES owl:purchasingPower 'medium' .
owl:userProf_ES owl:buyingBehaviour 'bargain' .
owl:userProf_ES owl:travelingBehaviour 'traveler' .
owl:userProf_ES owl:lblSporty true .
owl:userProf_ES owl:lblFamily true .
owl:userProf_ES owl:lblWorker false .
owl:userProf_ES owl:lblHealthy true .
owl:userProf_ES owl:lblGamer false .
owl:userProf_ES owl:hasNationality owl:ES .
owl:userProf_ES owl:hasSpokenLanguage owl:es_ES .
owl:userProf_ES owl:hasTravelingBehaviour owl:traveler .
owl:userProf_ES owl:hasBuyingBehaviour owl:bargain .
owl:userProf_ES owl:hasPurchasingPower owl:medium .
}
WHERE {
FILTER NOT EXISTS {
owl:userProf_ES rdf:type owl:UserProfile .
}
}