我是SPARQL的新手,并且一直在试验我的数据。我已经尝试过以下查询:
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX locah: <http://data.archiveshub.ac.uk/def/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
SELECT ?language ?date ?authorName ?authorSurname ?associatedDeeds ?repository
WHERE{
?x dcterms:identifier "R494Vol1".
?x locah:dateCreatedAccumulatedString ?date.
?x dcterms:language ?language.
?x dcterms:creator ?y.
?y foaf:firstName ?authorName.
?y foaf:family_name ?authorSurname.
?x locah:accessProvidedBy ?repository.
?x ore:aggregates ?associatedDeeds.
}
这将返回多个记录。但是language
,date
,authorName
,authorSurname
和repository
都是相同的。唯一更改的值为associatedDeeds
。能否获得包含associatedDeeds
列表的1条记录?
更新:
我尝试了group_concat
,它可以正常工作。但是,由于?associatedDeeds
是资源,这些资源将被转换为文字-字符串。有没有办法保留URI链接?
PREFIX dcterms: <http://purl.org/dc/terms/>
PREFIX locah: <http://data.archiveshub.ac.uk/def/>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ore: <http://www.openarchives.org/ore/terms/>
SELECT ?language ?date ?authorName ?authorSurname ?repository (group_concat(?associatedDeeds) as ?deeds)
WHERE{
?x dcterms:identifier "MS588".
?x locah:dateCreatedAccumulatedString ?date.
?x dcterms:language ?language.
?x dcterms:creator ?y.
?y foaf:firstName ?authorName.
?y foaf:family_name ?authorSurname.
?x locah:accessProvidedBy ?repository.
?x ore:aggregates ?associatedDeeds.
}
group by ?language ?date ?authorName ?authorSurname ?repository