query-3859f4a8290f28b81ac381f3eb1aba06

rq turtle/ttl

Everything with an Illuminated Manuscripts ID, with shelfmark and links to a Commons Category if it exists

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX schema: <http://schema.org/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT ?item ?itemLabel ?shelfmark ?groupLabel ?commonsCategory  WHERE {
  ?item wdt:P3702 ?group .

  OPTIONAL {?item wdt:P217 ?shelfmark}  .  # Shelfmark

   OPTIONAL {
      ?commonsCategoryFromItem schema:about ?item;
                               schema:isPartOf <https://commons.wikimedia.org/>.
      FILTER(STRSTARTS(STR(?commonsCategoryFromItem), "https://commons.wikimedia.org/wiki/Category:"))
    }
   OPTIONAL {
      ?item wdt:P910 ?catItem .
      ?commonsCategoryFromCatItem schema:about ?catItem;
                                  schema:isPartOf <https://commons.wikimedia.org/>.
      FILTER(STRSTARTS(STR(?commonsCategoryFromCatItem), "https://commons.wikimedia.org/wiki/Category:"))
   }
   BIND(COALESCE(?commonsCategoryFromItem, ?commonsCategoryFromCatItem) AS ?commonsCategory)

   SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v6("?catItem") v7("?commonsCategory"):::projected v1("?commonsCategoryFromCatItem") v2("?commonsCategoryFromItem") v4("?group") v3("?item"):::projected v5("?shelfmark"):::projected c9(["bd:serviceParam"]):::iri c6([https://commons.wikimedia.org/]):::iri c11(["#91;AUTO_LANGUAGE#93;,en"]):::literal v3 --"wdt:P3702"--> v4 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P217".-> v5 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v2 -."schema:about".-> v3 v2 --"schema:isPartOf"--> c6 end subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v3 -."wdt:P910".-> v6 v1 --"schema:about"--> v6 v1 --"schema:isPartOf"--> c6 end bind0[/"?commonsCategoryFromItem?commonsCategoryFromCatItem"/] v2 --o bind0 v1 --o bind0 bind0 --as--o v7 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c9 --"wikibase:language"--> c11 end