query-8d83a61976fddaf02f4e25f1a527f5b0

rq turtle/ttl

Länder-Infoboxen im Klexikon SELECT ?item ?itemLabel (MAX(?ew_in_millionen) as ?max_ew_in_mio) (GROUP_CONCAT(DISTINCT (IF(BOUND(?asklextitel),CONCAT('[[',?asklextitel,'|',?amtssprachenLabel,']]'),?amtssprachenLabel)); SEPARATOR=", ") as ?amtssprachen) (MAX(?flaeche_rund) as ?max_flaeche_rund) (GROUP_CONCAT(DISTINCT (IF(BOUND(?hsklextitel),CONCAT('[[',REPLACE(?hsklextitel, "_", " "),']]'),?hauptstadtLabel)); SEPARATOR=", ") as ?hauptstaedte) (GROUP_CONCAT(DISTINCT (COALESCE (?oberhaupt_titel_ausnahme, ?oberhaupt_bezLabel)); SEPARATOR=", ") as ?oberhaupt_bezeichnung) (GROUP_CONCAT(DISTINCT (IF(BOUND(?ohklextitel),CONCAT('[[',?ohklextitel,'|',?oberhauptLabel,']]'),?oberhauptLabel)); SEPARATOR=", ") as ?oberhaeupter) (GROUP_CONCAT(DISTINCT (CONCAT('[[',?kontinentLabel,']]')); SEPARATOR=" und ") as ?kontinente) ?safeFlaggenDatei ?safeKartenDatei ?titel_im_klexikon WHERE { ?item p:P31 [ps:P31 wd:Q6256]. # Finde alle Länder ?item wdt:P6573 ?titel_im_klexikon. # die es im Klexikon gibt ?item wdt:P1082 ?ewzahl. # und zeige ihre Einwohnerzahl BIND (STR(ROUND(?ewzahl / 1000) / 1000) as ?ew_in_millionen) # in Millionen ?item wdt:P2046 ?flaeche. # ihre Fläche BIND (STR(IF(?flaeche > 999, ROUND(?flaeche / 1000) * 1000,ROUND(?flaeche))) as ?flaeche_rund) # gerundet ?item wdt:P37 ?amtssprache. # ihre Amtssprache OPTIONAL {?amtssprache wdt:P6573 ?asklextitel} OPTIONAL { # Optional wg. Vatikanstadt ?item wdt:P36 ?hauptstadt. # ihre Hauptstädte OPTIONAL {?hauptstadt wdt:P6573 ?hsklextitel} } ?item wdt:P35 ?oberhaupt. # das Staatsoberhaupt OPTIONAL {?oberhaupt wdt:P6573 ?ohklextitel} OPTIONAL { ?item wdt:P1906/wdt:P279 ?oberhaupt_titel. FILTER (?oberhaupt_titel IN ( # einschränken auf bekannte / kinderverständliche Titel wd:Q30461, # Präsident wd:Q116, # Monarch wd:Q7645115, # Oberster Führer wd:Q166382, # Emir wd:Q683337, # Kofürst von Andorra wd:Q258045, # Capitano Reggente wd:Q844944 # Präsidium von Bosnien und Herzegowina )) OPTIONAL {?oberhaupt_titel wdt:P2521 ?oberhaupt_titel_weiblich.} } OPTIONAL {?oberhaupt wdt:P21 ?geschlecht.} FILTER (!BOUND(?oberhaupt_titel_weiblich) || LANG(?oberhaupt_titel_weiblich) = "de"). BIND (IF (BOUND(?oberhaupt_titel_weiblich) && BOUND(?geschlecht) && (?geschlecht = wd:Q6581072), IF(STR(?oberhaupt_titel_weiblich) = "Monarchin", wd:Q16511993, ?oberhaupt_titel_weiblich), IF(?oberhaupt_titel = wd:Q116, wd:Q12097, ?oberhaupt_titel)) as ?oberhaupt_bez ) OPTIONAL { # Länderspezifische Titel VALUES (?item ?oberhaupt_titel_ausnahme) { (wd:Q794 "Religionsführer") # Iran (wd:Q17 "Kaiser") # Japan (wd:Q40 "Bundespräsident") # Österreich (wd:Q183 "Bundespräsident") # Deutschland (wd:Q32 "Großherzog") # Luxemburg (wd:Q237 "Papst") # Vatikan (wd:Q347 "Fürst") # Liechtenstein (wd:Q683 "Häuptling") #Samoa } } ?item wdt:P41 ?flagge. BIND(REPLACE(wikibase:decodeUri(STR(?flagge)), "http://commons.wikimedia.org/wiki/Special:FilePath/", "") as ?flaggenDatei). BIND(REPLACE(?flaggenDatei, " ", "_") as ?safeFlaggenDatei) ?item wdt:P30 ?kontinent_alt. OPTIONAL { ?item wdt:P361/wdt:P706/wdt:P361 wd:Q27611 BIND (wd:Q29876 as ?mittelamerika) } BIND (COALESCE(?mittelamerika, ?kontinent_alt) as ?kontinent)

OPTIONAL { # Lagekarte: Grünes Land auf dem Globus ?item p:P242 ?p_karte1. ?p_karte1 pq:P195 wd:Q21167586. ?p_karte1 ps:P242 ?karte1. } OPTIONAL { # Lagekarte: Rotes Land auf dem Globus ?item p:P242 ?p_karte2. ?p_karte2 pq:P195 wd:Q47008743. ?p_karte2 ps:P242 ?karte2. } # Nimm Globus, falls vorhanden, sonst 2:1-Ausschnitt BIND(REPLACE(wikibase:decodeUri(STR(COALESCE(?karte1, ?karte2))), "http://commons.wikimedia.org/wiki/Special:FilePath/", "") as ?kartenDatei). BIND(REPLACE(?kartenDatei, " ", "_") as ?safeKartenDatei)

SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de". ?item rdfs:label ?itemLabel. ?amtssprache rdfs:label ?amtssprachenLabel. ?hauptstadt rdfs:label ?hauptstadtLabel. ?oberhaupt_bez rdfs:label ?oberhaupt_bezLabel. ?oberhaupt rdfs:label ?oberhauptLabel. ?kontinent rdfs:label ?kontinentLabel. } } GROUP BY ?item ?itemLabel ?safeFlaggenDatei ?safeKartenDatei ?titel_im_klexikon ORDER BY ?itemLabel

Use at

PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX ps: <http://www.wikidata.org/prop/statement/>
PREFIX pq: <http://www.wikidata.org/prop/qualifier/>
PREFIX p: <http://www.wikidata.org/prop/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#Länder-Infoboxen im Klexikon
SELECT
 ?item
 ?itemLabel
 (MAX(?ew_in_millionen) as ?max_ew_in_mio)
 (GROUP_CONCAT(DISTINCT (IF(BOUND(?asklextitel),CONCAT('[[',?asklextitel,'|',?amtssprachenLabel,']]'),?amtssprachenLabel)); SEPARATOR=", ") as ?amtssprachen)
 (MAX(?flaeche_rund) as ?max_flaeche_rund)
 (GROUP_CONCAT(DISTINCT (IF(BOUND(?hsklextitel),CONCAT('[[',REPLACE(?hsklextitel, "_", " "),']]'),?hauptstadtLabel)); SEPARATOR=", ") as ?hauptstaedte)
 (GROUP_CONCAT(DISTINCT (COALESCE (?oberhaupt_titel_ausnahme, ?oberhaupt_bezLabel)); SEPARATOR=", ") as ?oberhaupt_bezeichnung)
 (GROUP_CONCAT(DISTINCT (IF(BOUND(?ohklextitel),CONCAT('[[',?ohklextitel,'|',?oberhauptLabel,']]'),?oberhauptLabel)); SEPARATOR=", ") as ?oberhaeupter)
 (GROUP_CONCAT(DISTINCT (CONCAT('[[',?kontinentLabel,']]')); SEPARATOR=" und ") as ?kontinente)
 ?safeFlaggenDatei
 ?safeKartenDatei
 ?titel_im_klexikon
WHERE
{
 ?item p:P31 [ps:P31 wd:Q6256]. # Finde alle Länder
 ?item wdt:P6573 ?titel_im_klexikon. # die es im Klexikon gibt
 ?item wdt:P1082 ?ewzahl. # und zeige ihre Einwohnerzahl
 BIND (STR(ROUND(?ewzahl / 1000) / 1000) as ?ew_in_millionen) # in Millionen
 ?item wdt:P2046 ?flaeche. # ihre Fläche
 BIND (STR(IF(?flaeche > 999, ROUND(?flaeche / 1000) * 1000,ROUND(?flaeche))) as ?flaeche_rund) # gerundet
 ?item wdt:P37 ?amtssprache. # ihre Amtssprache
 OPTIONAL {?amtssprache wdt:P6573 ?asklextitel}
 OPTIONAL { # Optional wg. Vatikanstadt
  ?item wdt:P36 ?hauptstadt. # ihre Hauptstädte
  OPTIONAL {?hauptstadt wdt:P6573 ?hsklextitel}
 }
 ?item wdt:P35 ?oberhaupt. # das Staatsoberhaupt
 OPTIONAL {?oberhaupt wdt:P6573 ?ohklextitel}
 OPTIONAL {
  ?item wdt:P1906/wdt:P279* ?oberhaupt_titel.
  FILTER (?oberhaupt_titel IN ( # einschränken auf bekannte / kinderverständliche Titel
  wd:Q30461, # Präsident
  wd:Q116, # Monarch
  wd:Q7645115, # Oberster Führer
  wd:Q166382, # Emir
  wd:Q683337, # Kofürst von Andorra
  wd:Q258045, # Capitano Reggente
  wd:Q844944 # Präsidium von Bosnien und Herzegowina
  ))
  OPTIONAL {?oberhaupt_titel wdt:P2521 ?oberhaupt_titel_weiblich.}
 }
 OPTIONAL {?oberhaupt wdt:P21 ?geschlecht.}
 FILTER (!BOUND(?oberhaupt_titel_weiblich) || LANG(?oberhaupt_titel_weiblich) = "de").
 BIND (IF (BOUND(?oberhaupt_titel_weiblich) && BOUND(?geschlecht) && (?geschlecht = wd:Q6581072),
  IF(STR(?oberhaupt_titel_weiblich) = "Monarchin", wd:Q16511993, ?oberhaupt_titel_weiblich),
  IF(?oberhaupt_titel = wd:Q116, wd:Q12097, ?oberhaupt_titel)) as ?oberhaupt_bez
 )
 OPTIONAL { # Länderspezifische Titel
  VALUES (?item ?oberhaupt_titel_ausnahme) {
   (wd:Q794 "Religionsführer") # Iran
   (wd:Q17 "Kaiser") # Japan
   (wd:Q40 "Bundespräsident") # Österreich
   (wd:Q183 "Bundespräsident") # Deutschland
   (wd:Q32 "Großherzog") # Luxemburg
   (wd:Q237 "Papst") # Vatikan
   (wd:Q347 "Fürst") # Liechtenstein
   (wd:Q683 "Häuptling") #Samoa
  }
 }
 ?item wdt:P41 ?flagge.
 BIND(REPLACE(wikibase:decodeUri(STR(?flagge)), "http://commons.wikimedia.org/wiki/Special:FilePath/", "") as ?flaggenDatei).
 BIND(REPLACE(?flaggenDatei, " ", "_") as ?safeFlaggenDatei)
 ?item wdt:P30 ?kontinent_alt.
 OPTIONAL {
  ?item wdt:P361*/wdt:P706*/wdt:P361* wd:Q27611
  BIND (wd:Q29876 as ?mittelamerika)
 }
 BIND (COALESCE(?mittelamerika, ?kontinent_alt) as ?kontinent)

 OPTIONAL { # Lagekarte: Grünes Land auf dem Globus
  ?item p:P242 ?p_karte1.
  ?p_karte1 pq:P195 wd:Q21167586.
  ?p_karte1 ps:P242 ?karte1.
 }
 OPTIONAL { # Lagekarte: Rotes Land auf dem Globus
  ?item p:P242 ?p_karte2.
  ?p_karte2 pq:P195 wd:Q47008743.
  ?p_karte2 ps:P242 ?karte2.
 }
 # Nimm Globus, falls vorhanden, sonst 2:1-Ausschnitt
 BIND(REPLACE(wikibase:decodeUri(STR(COALESCE(?karte1, ?karte2))), "http://commons.wikimedia.org/wiki/Special:FilePath/", "") as ?kartenDatei).
 BIND(REPLACE(?kartenDatei, " ", "_") as ?safeKartenDatei)

 SERVICE wikibase:label {
  bd:serviceParam wikibase:language "[AUTO_LANGUAGE],de".
  ?item rdfs:label ?itemLabel.
  ?amtssprache rdfs:label ?amtssprachenLabel.
  ?hauptstadt rdfs:label ?hauptstadtLabel.
  ?oberhaupt_bez rdfs:label ?oberhaupt_bezLabel.
  ?oberhaupt rdfs:label ?oberhauptLabel.
  ?kontinent rdfs:label ?kontinentLabel.
 }
}
GROUP BY ?item ?itemLabel ?safeFlaggenDatei ?safeKartenDatei ?titel_im_klexikon
ORDER BY ?itemLabel

Query found at

graph TD classDef projected fill:lightgreen; classDef literal fill:orange; classDef iri fill:yellow; v10("?amtssprache") v37("?amtssprachen") v31("?amtssprachenLabel"):::projected v11("?asklextitel"):::projected v7("?ew_in_millionen"):::projected v6("?ewzahl") v8("?flaeche") v9("?flaeche_rund"):::projected v19("?flagge") v20("?flaggenDatei") v16("?geschlecht") v12("?hauptstadt") v32("?hauptstadtLabel"):::projected v39("?hauptstaedte") v13("?hsklextitel"):::projected v18("?item"):::projected v1("?itemLabel"):::projected v26("?karte1") v28("?karte2") v29("?kartenDatei") v24("?kontinent") v35("?kontinentLabel"):::projected v22("?kontinent_alt") v42("?kontinente") v36("?max_ew_in_mio") v38("?max_flaeche_rund") v23("?mittelamerika") v41("?oberhaeupter") v14("?oberhaupt") v34("?oberhauptLabel"):::projected v17("?oberhaupt_bez") v33("?oberhaupt_bezLabel"):::projected v40("?oberhaupt_bezeichnung") v3("?oberhaupt_titel") v18("?oberhaupt_titel_ausnahme"):::projected v2("?oberhaupt_titel_weiblich") v15("?ohklextitel"):::projected v25("?p_karte1") v27("?p_karte2") v21("?safeFlaggenDatei"):::projected v30("?safeKartenDatei"):::projected v5("?titel_im_klexikon"):::projected a1((" ")) a2((" ")) a3((" ")) a4((" ")) c29(["wd:Q21167586"]):::iri c33(["bd:serviceParam"]):::iri c10(["wd:Q6256"]):::iri c26(["wd:Q27611"]):::iri c35(["#91;AUTO_LANGUAGE#93;,de"]):::literal c31(["wd:Q47008743"]):::iri f0[["(not bound(?oberhaupt_titel_weiblich) || ?oberhaupt_titel_weiblich = 'de')"]] f0 --> v2 a1 --"p:statement/P31"--> c10 v18 --"p:P31"--> a1 v18 --"p:direct/P6573"--> v5 v18 --"p:direct/P1082"--> v6 bind1[/"str(numeric-round(?ewzahl / '1000^^xsd:integer') / '1000^^xsd:integer')"/] v6 --o bind1 bind1 --as--o v7 v18 --"p:direct/P2046"--> v8 bind2[/"str(if(?flaeche > '999^^xsd:integer',numeric-round(?flaeche / '1000^^xsd:integer') * '1000^^xsd:integer',numeric-round(?flaeche)))"/] v8 --o bind2 bind2 --as--o v9 v18 --"p:direct/P37"--> v10 subgraph optional0["(optional)"] style optional0 fill:#bbf,stroke-dasharray: 5 5; v10 -."p:direct/P6573".-> v11 end subgraph optional1["(optional)"] style optional1 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:direct/P36".-> v12 subgraph optional2["(optional)"] style optional2 fill:#bbf,stroke-dasharray: 5 5; v12 -."p:direct/P6573".-> v13 end end v18 --"p:direct/P35"--> v14 subgraph optional3["(optional)"] style optional3 fill:#bbf,stroke-dasharray: 5 5; v14 -."p:direct/P6573".-> v15 end subgraph optional4["(optional)"] style optional4 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:direct/P1906".-> a2 a2 --"p:direct/P279"--> v3 subgraph optional5["(optional)"] style optional5 fill:#bbf,stroke-dasharray: 5 5; v3 -."p:direct/P2521".-> v2 end end subgraph optional6["(optional)"] style optional6 fill:#bbf,stroke-dasharray: 5 5; v14 -."p:direct/P21".-> v16 end bind3[/"if(bound(?oberhaupt_titel_weiblich)bound(?geschlecht)?geschlecht = 'wd:Q6581072',if(str(?oberhaupt_titel_weiblich) = 'Monarchin','wd:Q16511993',?oberhaupt_titel_weiblich),if(?oberhaupt_titel = 'wd:Q116','wd:Q12097',?oberhaupt_titel))"/] v2 --o bind3 v16 --o bind3 v3 --o bind3 bind3 --as--o v17 subgraph optional7["(optional)"] style optional7 fill:#bbf,stroke-dasharray: 5 5; bind4[/VALUES ?item ?oberhaupt_titel_ausnahme/] bind4-->v18 bind4-->v18 bind40(["wd:Q794"]) bind40 --> bind4 bind41(["Religionsführer"]) bind41 --> bind4 bind42(["wd:Q17"]) bind42 --> bind4 bind43(["Kaiser"]) bind43 --> bind4 bind44(["wd:Q40"]) bind44 --> bind4 bind45(["Bundespräsident"]) bind45 --> bind4 bind46(["wd:Q183"]) bind46 --> bind4 bind47(["Bundespräsident"]) bind47 --> bind4 bind48(["wd:Q32"]) bind48 --> bind4 bind49(["Großherzog"]) bind49 --> bind4 bind410(["wd:Q237"]) bind410 --> bind4 bind411(["Papst"]) bind411 --> bind4 bind412(["wd:Q347"]) bind412 --> bind4 bind413(["Fürst"]) bind413 --> bind4 bind414(["wd:Q683"]) bind414 --> bind4 bind415(["Häuptling"]) bind415 --> bind4 end v18 -."p:direct/P41".-> v19 bind5[/"replace(http://wikiba.se/ontology#decodeUri(str(?flagge)),'http://commons.wikimedia.org/wiki/Special:FilePath/','')"/] v19 --o bind5 bind5 --as--o v20 bind6[/"replace(?flaggenDatei,' ','_')"/] v20 --o bind6 bind6 --as--o v21 v18 --"p:direct/P30"--> v22 subgraph optional8["(optional)"] style optional8 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:direct/P361".-> a3 a3 --"p:direct/P706"--> a4 a4 --"p:direct/P361"--> c26 bind7[/"'wd:Q29876'"/] bind7 --as--o v23 end bind8[/"?mittelamerika?kontinent_alt"/] v23 --o bind8 v22 --o bind8 bind8 --as--o v24 subgraph optional9["(optional)"] style optional9 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:P242".-> v25 v25 --"p:qualifier/P195"--> c29 v25 --"p:statement/P242"--> v26 end subgraph optional10["(optional)"] style optional10 fill:#bbf,stroke-dasharray: 5 5; v18 -."p:P242".-> v27 v27 --"p:qualifier/P195"--> c31 v27 --"p:statement/P242"--> v28 end bind9[/"replace(http://wikiba.se/ontology#decodeUri(str(?karte1?karte2)),'http://commons.wikimedia.org/wiki/Special:FilePath/','')"/] v26 --o bind9 v28 --o bind9 bind9 --as--o v29 bind10[/"replace(?kartenDatei,' ','_')"/] v29 --o bind10 bind10 --as--o v30 subgraph s1["http://wikiba.se/ontology#label"] style s1 stroke-width:4px; c33 --"wikibase:language"--> c35 v18 --"rdfs:label"--> v1 v10 --"rdfs:label"--> v31 v12 --"rdfs:label"--> v32 v17 --"rdfs:label"--> v33 v14 --"rdfs:label"--> v34 v24 --"rdfs:label"--> v35 end bind18[/"max(?ew_in_millionen)"/] v7 --o bind18 bind18 --as--o v36 bind19[/"if(bound(?asklextitel),concat('#91;#91;',?asklextitel,'|',?amtssprachenLabel,'#93;#93;'),?amtssprachenLabel)"/] v11 --o bind19 v31 --o bind19 bind19 --as--o v37 bind20[/"max(?flaeche_rund)"/] v9 --o bind20 bind20 --as--o v38 bind21[/"if(bound(?hsklextitel),concat('#91;#91;',replace(?hsklextitel,'_',' '),'#93;#93;'),?hauptstadtLabel)"/] v13 --o bind21 v32 --o bind21 bind21 --as--o v39 bind22[/"?oberhaupt_titel_ausnahme?oberhaupt_bezLabel"/] v18 --o bind22 v33 --o bind22 bind22 --as--o v40 bind23[/"if(bound(?ohklextitel),concat('#91;#91;',?ohklextitel,'|',?oberhauptLabel,'#93;#93;'),?oberhauptLabel)"/] v15 --o bind23 v34 --o bind23 bind23 --as--o v41 bind24[/"concat('#91;#91;',?kontinentLabel,'#93;#93;')"/] v35 --o bind24 bind24 --as--o v42