CONSTRUCT publishes public library records as RDF and includes online copies where available.
public-catalog-rq.rq · data/public-catalog-rq.ttl · output · proof · check · playground
The question
A library wants to publish its public local history and oral history items using Schema.org. Each item should have a title and, where available, the URL of its online copy.
Historical background
The first SPARQL Query Language Recommendation in 2008 included CONSTRUCT, a query form that creates an RDF graph from matches in another graph. That makes it possible to publish a view of selected records. This example constructs a public catalog from one set of source records. W3C, 2008 SPARQL Recommendation
What we tell eyemind
VALUES names the two collections, and the pattern requires a public item
with a title. OPTIONAL looks up its online copy.
CONSTRUCT {
?item a schema:CreativeWork ;
schema:name ?title ;
schema:url ?url .
}
WHERE {
VALUES ?collection { :localHistory :oralHistory }
?item :collection ?collection ; :title ?title ; :public true .
OPTIONAL { ?item :onlineCopy ?url }
}
What eyemind concludes
The Turtle output contains two records and five triples. The harbor map gets an online URL. The dockside interview has no bound URL, so its type and title are emitted on their own. The restricted field notes and the astronomy collection’s star chart are outside the requested selection.
PREFIX : <https://example.org/catalog#>
PREFIX schema: <https://schema.org/>
:harborMap a schema:CreativeWork .
:dockInterview a schema:CreativeWork .
:harborMap schema:name "Harbor map" .
:dockInterview schema:name "Dockside interview" .
:harborMap schema:url <https://example.org/library/harbor-map> .
The check report represents each triple as a Logic Script term. Here is the one for the URL.
sparql_triple(iri('https://example.org/catalog#harborMap'), iri('https://schema.org/url'), iri('https://example.org/library/harbor-map'))
What the proof establishes
The saved report ends with verdict('checked'). The checker verifies the
solutions of the query pattern against the data and checks that applying
the template yields exactly the reported triples.
Try it
Run these commands from the repository root.
node bin/eyemind.js examples/public-catalog-rq.rq examples/data/public-catalog-rq.ttl
node bin/eyemind.js --proof examples/public-catalog-rq.rq examples/data/public-catalog-rq.ttl
node bin/eyemind.js --check-proof examples/proof/public-catalog-rq.js examples/public-catalog-rq.rq examples/data/public-catalog-rq.ttl
