query-8bd189eb418bea965c0fe1d60b40a324

rq turtle/ttl

PropertiesCommons category (P373)

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX bd: <http://www.bigdata.com/rdf#>
SELECT (IRI(concat("https://commons.wikimedia.org/wiki/", ?category)) as ?categoryLink) ?categoryName 
  (IF(BOUND(?sortkey),?sortkey,?categoryName) as ?sortValue) (IRI(CONCAT(STR(wd:), ?sitelinkQ)) as ?catSitelinkItem) 
  ?commonsCatItem ?commonsCatItemLabel {
  SERVICE wikibase:mwapi {
     bd:serviceParam wikibase:api "Generator" .
     bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
     bd:serviceParam mwapi:gcmtitle "Category:Pages using authority control without Wikidata link" .
     bd:serviceParam mwapi:generator "categorymembers" .
     bd:serviceParam mwapi:gcmtype "subcat" .
     bd:serviceParam mwapi:gcmlimit "max" .
     bd:serviceParam mwapi:gcmsort "sortkey" .
     bd:serviceParam mwapi:gcmdir "ascending" .
     bd:serviceParam mwapi:gcmstartsortkeyprefix "A" .
     bd:serviceParam mwapi:prop "pageprops" .
     bd:serviceParam mwapi:ppprop "defaultsort|wikibase_item" .
     ?category wikibase:apiOutput mwapi:title  .
     ?sortkey wikibase:apiOutput "pageprops/@defaultsort" .
     ?sitelinkQ wikibase:apiOutput "pageprops/@wikibase_item" .
  }
  BIND(substr(?category,10) as ?categoryName) .
  OPTIONAL { 
    ?commonsCatItem wdt:P373 ?categoryName .
    SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
  }
  FILTER ( BOUND(?commonsCatItem) || BOUND(?sitelinkQ) ) .
}
ORDER BY ?sortValue

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v8("?catSitelinkItem") v4("?category"):::projected v7("?categoryLink") v6("?categoryName"):::projected v2("?commonsCatItem"):::projected v3("?sitelinkQ"):::projected v8("?sortValue") v5("?sortkey"):::projected c20(["A"]):::literal c24(["defaultsort|wikibase_item"]):::literal c12(["subcat"]):::literal c28(["pageprops/@wikibase_item"]):::literal c8(["Category:Pages using authority control without Wikidata link"]):::literal c16(["sortkey"]):::literal c2(["bd:serviceParam"]):::iri c22(["pageprops"]):::literal c6(["commons.wikimedia.org"]):::literal c14(["max"]):::literal c18(["ascending"]):::literal c10(["categorymembers"]):::literal c27(["pageprops/@defaultsort"]):::literal c32(["#91;AUTO_LANGUAGE#93;,en"]):::literal c26(["mwapi:title"]):::iri c4(["Generator"]):::literal f0[["(bound(?commonsCatItem) || bound(?sitelinkQ))"]] f0 --> v2 f0 --> v3 subgraph s1["http://wikiba.se/ontology#mwapi"] style s1 stroke-width:4px; c2 --"mwapi:api"--> c4 c2 --"mwapi:endpoint"--> c6 c2 --"mwapi:gcmtitle"--> c8 c2 --"mwapi:generator"--> c10 c2 --"mwapi:gcmtype"--> c12 c2 --"mwapi:gcmlimit"--> c14 c2 --"mwapi:gcmsort"--> c16 c2 --"mwapi:gcmdir"--> c18 c2 --"mwapi:gcmstartsortkeyprefix"--> c20 c2 --"mwapi:prop"--> c22 c2 --"mwapi:ppprop"--> c24 v4 --"mwapi:apiOutput"--> c26 v5 --"mwapi:apiOutput"--> c27 v3 --"mwapi:apiOutput"--> c28 end bind1[/"substring(?category,'10^^xsd:integer')"/] v4 --o bind1 bind1 --as--o v6 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P373".-> v6 subgraph s2["http://wikiba.se/ontology#label"] style s2 stroke-width:4px; c2 --"mwapi:language"--> c32 end end bind2[/"concat('https://commons.wikimedia.org/wiki/',?category)"/] v4 --o bind2 bind2 --as--o v7 bind3[/"if(bound(?sortkey),?sortkey,?categoryName)"/] v5 --o bind3 v6 --o bind3 bind3 --as--o v8 bind4[/"concat(str('wd:'),?sitelinkQ)"/] v3 --o bind4 bind4 --as--o v8