query-dffdbd06cb3339c07d395febd89f227e

rq turtle/ttl

PropertiesVIAF ID (P214)

Use at

PREFIX mwapi: <http://wikiba.se/ontology#>
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
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) ?viaf ?item
  WHERE {
  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 "50" .
     bd:serviceParam mwapi:gcmsort "sortkey" .
     bd:serviceParam mwapi:gcmdir "ascending" .
     bd:serviceParam mwapi:gcmstartsortkeyprefix "A" .
     bd:serviceParam mwapi:prop "pageprops|revisions" .
     bd:serviceParam mwapi:ppprop "defaultsort" .
     bd:serviceParam mwapi:rvprop "content" .
     ?category wikibase:apiOutput mwapi:title  .
     ?sortkey wikibase:apiOutput "pageprops/@defaultsort" .
     ?cnt wikibase:apiOutput "revisions/rev/text()" .
  }
  BIND(substr(?category,10) as ?categoryName) .
  BIND(REPLACE(STRBEFORE(STRAFTER(?cnt,CONCAT("{","{Authority control")),CONCAT("}","}")), ".*\\|\\s*VIAF\\s*=\\s*(\\d+).*", "$1") as ?viaf) .
  OPTIONAL { ?item wdt:P214 ?viaf }
  FILTER ( BOUND(?item) ) .
}
ORDER BY ?sortValue

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v3("?category"):::projected v8("?categoryLink") v6("?categoryName"):::projected v5("?cnt") v2("?item"):::projected v9("?sortValue") v4("?sortkey"):::projected v7("?viaf"):::projected c20(["A"]):::literal c12(["subcat"]):::literal c26(["content"]):::literal c8(["Category:Pages using authority control without Wikidata link"]):::literal c22(["pageprops|revisions"]):::literal c16(["sortkey"]):::literal c2(["bd:serviceParam"]):::iri c14(["50"]):::literal c6(["commons.wikimedia.org"]):::literal c24(["defaultsort"]):::literal c30(["revisions/rev/text()"]):::literal c18(["ascending"]):::literal c10(["categorymembers"]):::literal c29(["pageprops/@defaultsort"]):::literal c28(["mwapi:title"]):::iri c4(["Generator"]):::literal f0[["bound(?item)"]] f0 --> v2 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 c2 --"mwapi:rvprop"--> c26 v3 --"mwapi:apiOutput"--> c28 v4 --"mwapi:apiOutput"--> c29 v5 --"mwapi:apiOutput"--> c30 end bind1[/"substring(?category,'10^^xsd:integer')"/] v3 --o bind1 bind1 --as--o v6 bind2[/"replace(substring-before(substring-after(?cnt,concat('{','{Authority control')),concat('}','}')),'.*\|\s*VIAF\s*=\s*(\d+).*','$1')"/] v5 --o bind2 bind2 --as--o v7 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v2 -."wdt:P214".-> v7 end bind3[/"concat('https://commons.wikimedia.org/wiki/',?category)"/] v3 --o bind3 bind3 --as--o v8 bind4[/"if(bound(?sortkey),?sortkey,?categoryName)"/] v4 --o bind4 v6 --o bind4 bind4 --as--o v9