A set of SPARQL examples that are used in different TGX resources
License: https://www.gnu.org/licenses/gpl-3.0
Uses method in: https://github.com/WDscholia/scholia/tree/master/scholia/app/templates/catalogue_items.sparql
Catalogue aspect: items
PREFIX bd: <http://www.bigdata.com/rdf#>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX target: <http://www.wikidata.org/entity/Q51467536>
SELECT
?number
?code
?item ?itemLabel ?itemDescription
WHERE {
# Find catalogue items
?item p:P972 ?catalogue_statement .
?catalogue_statement ps:P972 target: .
# Optionally the catalogue code or the serial order
OPTIONAL { ?catalogue_statement pq:P528 | pq:P1545 ?code }
# For numerical sorting the catalogue code should be converted to an integer
BIND(xsd:integer(?code) AS ?number)
# Label the result
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],mul,en,da,es,fr,jp,nl,no,ru,sv,zh". }
}
ORDER BY ?number ?code
LIMIT 1000
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?catalogue_statement")
v2("?code"):::projected
v3("?item"):::projected
v5("?number"):::projected
c7([http://www.bigdata.com/rdf#serviceParam]):::iri
c3([http://www.wikidata.org/entity/Q51467536]):::iri
c9(["#91;AUTO_LANGUAGE#93;,mul,en,da,es,fr,jp,nl,no,ru,sv,zh"]):::literal
v3 --"p:P972"--> v4
v4 --"p:statement/P972"--> c3
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
v4 -."p:qualifier/P1545".-> v2
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"p:qualifier/P528"--> v2
end
union0r <== or ==> union0l
end
end
bind0[/"http://www.w3.org/2001/XMLSchema#integer(?code)"/]
v2 --o bind0
bind0 --as--o v5
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c7 --"wikibase:language"--> c9
end