我在这个查询中使用Jena ARQ:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX sc: <http://iiif.io/api/presentation/2#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX as: <http://www.w3.org/ns/activitystreams#>
CONSTRUCT {?collectionIRI rdf:type sc:Collection .
?collectionIRI as:items ?manifest .
?manifest rdf:type sc:Manifest}
WHERE {GRAPH ?g {?manifest rdf:type sc:Manifest .
BIND (URI(STR(CONCAT("https://api.repository.org/orgs/example.domain.org/collections/" , STRUUID()))) AS ?collectionIRI) .
FILTER(regex(str(?manifest),"example.domain.org"))
}}
目的是通过将?collectionIRI
绑定到域名(例如“example.domain.org” - 查询参数)来创建单个 STRUUID()
。
使用此查询,结果集中的每个?manifest
都绑定到不同的?collectionIRI
,结果如下所示:
{
"@graph": [
{
"@id": "https://api.repository.org/orgs/example.domain.org/collections/0342aaf2-b772-48ea-be90-298a555ef5ab",
"@type": "sc:Collection",
"items": "http://example.domain.org/unescoCzechReformation/AIPDIG-NKCR__X_C_23______3CKR674-cs/"
},
{
"@id": "https://api.repository.org/orgs/example.domain.org/collections/04782c88-81cf-4d7b-8ac6-f15d83f094a5",
"@type": "sc:Collection",
"items": "http://example.domain.org/unescoCzechReformation/AIPDIG-NKCR__VIII_G_26___38E5KUD-cs/"
}
]
}
而不是所需的结果:
{
"@graph": [
{
"@id": "https://api.repository.org/orgs/example.domain.org/collections/0342aaf2-b772-48ea-be90-298a555ef5ab",
"@type": "sc:Collection",
"items": [
"http://example.domain.org/unescoCzechReformation/AIPDIG-NKCR__VIII_B_6____30XYOX6-cs/",
"http://example.domain.org/unescoCzechReformation/AIPDIG-NKCR__I_E_45______2KDU8A5-cs/"
]
}
]
}
是否可以使用CONSTRUCT限制BIND范围?