我是一个完全的语义网初学者和RDF4J初学者。目前,我有一些RDF,并且我不能编写一个简单的构造查询来根据主题值选择所有相关语句。我有这个:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="http://example.org/cocktail#Mimosa">
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
<prefLabel xmlns="http://www.w3.org/2004/02/skos/core#">Mimosa</prefLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">bla</altLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">huuh</altLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">owiii</altLabel>
<broader xmlns="http://www.w3.org/2004/02/skos/core#">Wine cocktail</broader>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/cocktail#White Russian">
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
<prefLabel xmlns="http://www.w3.org/2004/02/skos/core#">White Russian</prefLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">Ruski</altLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">kasdnjkldfan</altLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">oasdasi</altLabel>
<broader xmlns="http://www.w3.org/2004/02/skos/core#">Wine cocktail</broader>
</rdf:Description>
</rdf:RDF>
我想要编写一个简单的查询,它以prefLabel作为参数并选择整个语句块(描述中的所有内容,包括描述本身)。例如,我为prefLabel设置了一个值"Mimosa“,现在我希望得到这个值:
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="http://example.org/cocktail#Mimosa">
<rdf:type rdf:resource="http://www.w3.org/2004/02/skos/core#Concept"/>
<prefLabel xmlns="http://www.w3.org/2004/02/skos/core#">Mimosa</prefLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">bla</altLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">huuh</altLabel>
<altLabel xmlns="http://www.w3.org/2004/02/skos/core#">owiii</altLabel>
<broader xmlns="http://www.w3.org/2004/02/skos/core#">Wine cocktail</broader>
</rdf:Description>
</rdf:RDF>
发布于 2020-12-01 13:36:50
您可以执行以下操作:
CONSTRUCT
WHERE {
?c a skos:Concept ;
skos:prefLabel "Mimosa" ;
?property ?value .
}说明:WHERE子句的第一行选择skos:Concept类型的所有资源。第二行进一步将其范围缩小到那些具有值为"Mimosa"的prefLabel的概念。最后一行获取所选概念的所有可能的属性和值。
提示:不关注RDF/XML语法会有所帮助。从图形的角度考虑RDF,而不是XML文档。它可能会帮助您以不同的语法处理RDF文件,比如Turtle (它也更接近SPARQL中的工作方式)。
https://stackoverflow.com/questions/65080771
复制相似问题