query-12148d20b0d52cd6ab53550c6af475f2
PropertiesCommons category (P373)
Use at
- https://query.wikidata.org/sparql
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/", ?template)) as ?templateLink) ?templateName ?categoryName ?commonsCatItem ?commonsCatItemLabel {
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Generator" .
bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
bd:serviceParam mwapi:gcmtitle "Category:Creator templates without Wikidata link" .
bd:serviceParam mwapi:generator "categorymembers" .
bd:serviceParam mwapi:gcmtype "page" .
bd:serviceParam mwapi:gcmlimit "max" .
bd:serviceParam mwapi:gcmsort "timestamp" .
bd:serviceParam mwapi:gcmdir "descending" .
?template wikibase:apiOutput mwapi:title .
}
SERVICE wikibase:mwapi {
bd:serviceParam wikibase:api "Categories" .
bd:serviceParam wikibase:endpoint "commons.wikimedia.org" .
bd:serviceParam mwapi:titles ?template .
bd:serviceParam mwapi:clshow "!hidden" .
?category wikibase:apiOutput mwapi:category .
}
BIND(substr(?template,9) as ?templateName) .
BIND(substr(?category,10) as ?categoryName) .
OPTIONAL {
?commonsCatItem wdt:P373 ?categoryName .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" }
}
FILTER ( BOUND(?commonsCatItem) ) .
}
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v3("?category")
v5("?categoryName"):::projected
v1("?commonsCatItem"):::projected
v2("?template"):::projected
v6("?templateLink")
v4("?templateName"):::projected
c18(["descending"]):::literal
c8(["Category:Creator templates without Wikidata link"]):::literal
c2(["bd:serviceParam"]):::iri
c25(["mwapi:category"]):::iri
c24(["!hidden"]):::literal
c6(["commons.wikimedia.org"]):::literal
c16(["timestamp"]):::literal
c14(["max"]):::literal
c21(["Categories"]):::literal
c10(["categorymembers"]):::literal
c29(["#91;AUTO_LANGUAGE#93;,en"]):::literal
c12(["page"]):::literal
c20(["mwapi:title"]):::iri
c4(["Generator"]):::literal
f0[["bound(?commonsCatItem)"]]
f0 --> v1
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
v2 --"mwapi:apiOutput"--> c20
end
subgraph s1["http://wikiba.se/ontology#mwapi"]
style s1 stroke-width:4px;
c2 --"mwapi:api"--> c21
c2 --"mwapi:endpoint"--> c6
c2 --"mwapi:titles"--> v2
c2 --"mwapi:clshow"--> c24
v3 --"mwapi:apiOutput"--> c25
end
bind1[/"substring(?template,'9^^xsd:integer')"/]
v2 --o bind1
bind1 --as--o v4
bind2[/"substring(?category,'10^^xsd:integer')"/]
v3 --o bind2
bind2 --as--o v5
subgraph optional0["(optional)"]
style optional0 fill:#bbf,stroke-dasharray: 5 5;
v1 -."wdt:P373".-> v5
subgraph s2["http://wikiba.se/ontology#label"]
style s2 stroke-width:4px;
c2 --"mwapi:language"--> c29
end
end
bind3[/"concat('https://commons.wikimedia.org/wiki/',?template)"/]
v2 --o bind3
bind3 --as--o v6