SPARQL如何查询返回无命名空间前缀的startDate日期属性值
问题解决说明
你遇到的无显式前缀属性无法查询的问题,核心原因是startDate/endDate继承了RDF片段中声明的默认命名空间http://schema.org/,只需要在SPARQL中补充对应命名空间的前缀声明,再添加日期属性的匹配规则即可。
如果需要保留没有填写日期的实体记录,用OPTIONAL包裹日期匹配规则;如果只需要返回同时包含日期的实体,去掉OPTIONAL关键字即可。
修改后完整查询语句
PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX skos:<http://www.w3.org/2004/02/skos/core#> PREFIX schema:<http://schema.org/> SELECT ?s ?prefLabel ?scopeNote ?startDate ?endDate WHERE { ?s skos:inScheme <https://data.niod.nl/WO2_Thesaurus/events/4329> . ?s skos:prefLabel ?prefLabel . ?s skos:scopeNote ?scopeNote . FILTER (lang(?prefLabel)= "nl") . OPTIONAL {?s schema:startDate ?startDate .} OPTIONAL {?s schema:endDate ?endDate .} } LIMIT 50
内容的提问来源于stack exchange,提问作者Jan Willem Tulp
相关产品推荐
相关产品推荐

