Template:SPARQL/doc

From MaRDI portal
Revision as of 15:39, 23 June 2025 by Admin (talk | contribs) (1 revision imported)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Template:Ombox

Usage

<templatedata> { "description": "This template displays SPARQL query with syntax highlighting, prefixes and link to WDQS site to run the query. ", "params": { "p": { "label": "p", "type": "boolean", "required": false, "suggested": false, "deprecated": false, "description": "Produce p: prefix if set" }, "q": { "label": "q", "type": "boolean", "required": false, "suggested": false, "deprecated": false, "description": "Produce q: prefix if set" }, "v": { "label": "v", "type": "boolean", "required": false, "suggested": false, "deprecated": false, "description": "Produce v: prefix if set" }, "query": { "label": "query", "type": "string", "required": true, "suggested": false, "deprecated": false, "description": "SPARQL query" }, "extraprefix": { "type": "string", "required": false, "suggested": false, "deprecated": false, "description": "Extra prefixes to be added" }, "state": { "type": "string", "required": false, "suggested": false, "deprecated": false, "description": "Either \"collapsed\" or \"expanded\", both make the query code collapsible, \"collapsed\" makes it start collapsed. In a list (\"*\" or \"#\" at beginning of line) the \"Collapse\"/\"Expand\" toggle button is displayed next to the link to the Wikidata Query Service." }, "label": { "type": "content", "required": false, "suggested": false, "deprecated": false, "description": "Text to be used as the label of the link to the Wikidata Query Service", "default": "Try it!" }, "shortURL": { "type": "string", "required": false, "suggested": false, "deprecated": false, "description": "slug of the query's short URL, as generated by the WMF URL shortener - for example, for https://w.wiki/37j enter just 37j" }, "project": { "label": "project", "type": "string", "required": false, "suggested": false, "deprecated": false, "description": "project name: 'wd' for Wikidata (default), 'sdc' for Structured Data on Commons, or the URL of another compatible query service (e.g. 'https://database.factgrid.de/query/' – note that this must be a page with the query UI frontend, not the SPARQL endpoint itself)" }, "embedded": { "label": "Embedded", "type": "string", "required": false, "suggested": true, "deprecated": false, "description": "Shall the link direct user to the results (yes) or to the code (no, empty)" }, "highlight": { "label": "Highlight", "description": "Line(s) in the source code to be highlighted. See mediawiki:Extension:SyntaxHighlight for the supported syntax", "example": "3-7", "type": "line" }, "qlever": { "label": "QLever", "description": "Add link to QLever (only supported for project=wd or project=sdc)", "type": "boolean", "default": "false", "example": "true"

       },

"scholarly": { "label": "query-scholarly", "description": "Add link to query-scholarly (only supported for project=wd)", "type": "boolean", "default": "false", "example": "true" }, "orb": { "label": "Orb Open Graph", "description": "Add link to Orb Open Graph", "example": "true", "type": "boolean", "default": "false" } }, "format": "block" } </templatedata>

Példák (hu) / Vuesiehtimmieh (sma) / Contoh (ms) / Engreifftiau (cy) / Shembuj (sq) / Eksempler (da) / Exemple (ro) / (ja) / exempel (sv) / Приклади (uk) / 範例 (zh-hant) / Esimerkit (fi) / Ekzemploj (eo) / Příklady (cs) / Esempi (it) / উদাহরণসমূহ (bn) / Exemples (fr) / Прыклады (be-tarask) / Beispiele (de) / Παραδείγματα (el) / דוגמאות (he) / Exemplos (pt) / Ovdamearkkat (se) / 용례들 (ko) / Mînak (ku) / Примери (sr) / Примери (mk) / چونتوه (ms-arab) / Exemplos (pt-br) / Døme (nn) / ตัวอย่าง (th) / Mifano (sw) / Eksempler (nb) / Voorbeelden (nl) / Contoh (id) / Примеры (ru) / Ví dụ (vi) / Examples (en-gb) / Examples (en) / أمثلة (ar) / 示例 (zh-hans) / ezenpi (vec)

Wikicode Rendered result
{{SPARQL|query=SELECT DISTINCT ?person ?name ?language ?death (URI(CONCAT("https://www.gutenberg.org/ebooks/author/", ?gutenberg)) AS ?gberglink) WHERE {
  ?person wdt:P1938 ?gutenberg.
  ?person wdt:P570 ?death. # Dead people only
  MINUS {
    ?enws schema:about ?person.
    ?enws schema:isPartOf <https://en.wikisource.org/>
  }
  OPTIONAL {?person wdt:P1412 ?lang}.
  FILTER (!BOUND(?lang) {{!}}{{!}} ?lang = wd:Q1860) # Language: English or absent
  BIND(IF(BOUND(?lang),"English","Not specified") AS ?language
)  ?person rdfs:label ?name.
  FILTER((LANG(?name)) = "en")
}
ORDER BY ?death
|shortURL=37j}}
SELECT DISTINCT ?person ?name ?language ?death (URI(CONCAT("https://www.gutenberg.org/ebooks/author/", ?gutenberg)) AS ?gberglink) WHERE {
  ?person wdt:P1938 ?gutenberg.
  ?person wdt:P570 ?death. # Dead people only
  MINUS {
    ?enws schema:about ?person.
    ?enws schema:isPartOf <https://en.wikisource.org/>
  }
  OPTIONAL {?person wdt:P1412 ?lang}.
  FILTER (!BOUND(?lang) || ?lang = wd:Q1860) # Language: English or absent
  BIND(IF(BOUND(?lang),"English","Not specified") AS ?language
)  ?person rdfs:label ?name.
  FILTER((LANG(?name)) = "en")
}
ORDER BY ?death
¡Pruébalo! (es) / Próbáld ki! (hu) / ¡Pruébalo! (ast) / Prova-ho! (ca) / Es kann versucht werden! (de-ch) / Ceisio! (cy) / Try it! (en-gb) / Փորձի՛ր (hy) / 试一试! (zh) / Prøv det! (da) / Deneyin! (tr) / 試す! (ja) / Testa! (sv) / Versuchen Sie es! (de-formal) / 試一試! (zh-hant) / Versuche es! (de) / Kokeile! (fi) / Δοκιμάστε το! (el) / Provu ĝin! (eo) / Zkuste to! (cs) / Isprobajte! (bs) / Provalo! (it) / এটি চেষ্টা করে দেখুন! (bn) / Essayez ! (fr) / پرشن کرو (pnb) / Паспрабуйце! (be-tarask) / de-at (1) / Виконати! (uk) / לנסות את זה! (he) / SPARQL 쿼리 실행하기 (ko) / Biceribîne! (ku) / Probeer! (nl) / Experimenta! (pt) / ਪ੍ਰਸ਼ਨ ਕਰੋ (pa) / Izmēģini! (lv) / Prøv sjølv (nn) / Испробајте! (sr) / Cobalah! (id) / Пробајте! (mk) / Experimente! (pt-br) / جالنکن! (ms-arab) / ทดลองใช้ (th) / Wypróbuj! (pl) / Prøv selv! (nb) / 試試看! (zh-tw) / Jalankan! (ms) / Încercați! (ro) / Выполнить запрос (ru) / Provoje (sq) / Try it! (en) / تجربة! (ar) / 试一试! (zh-hans) / Оскалтэ! (udm) (https://w.wiki/37j)
{{SPARQL|embedded=yes|query=
#defaultView:Map
SELECT DISTINCT ?airport ?coor WHERE {
  ?airport (wdt:P31/wdt:P279) wd:Q62447; wdt:P17 wd:Q142.
    ?airport     wdt:P625 ?coor.
  MINUS { ?airport (wdt:P576|wdt:P582|wdt:P3999) ?dispar. }
  MINUS {
    ?airport wdt:P5817 ?interdit.
    VALUES ?interdit {
      wd:Q811683
      wd:Q63065035
      wd:Q12377751
      wd:Q30108381
      wd:Q11639308
    } 
  }
} |highlight=1, 8-14 }}
#defaultView:Map
SELECT DISTINCT ?airport ?coor WHERE {
  ?airport (wdt:P31/wdt:P279) wd:Q62447; wdt:P17 wd:Q142.
    ?airport     wdt:P625 ?coor.
  MINUS { ?airport (wdt:P576|wdt:P582|wdt:P3999) ?dispar. }
  MINUS {
    ?airport wdt:P5817 ?interdit.
    VALUES ?interdit {
      wd:Q811683
      wd:Q63065035
      wd:Q12377751
      wd:Q30108381
      wd:Q11639308
    } 
  }
}
¡Pruébalo! (es) / Próbáld ki! (hu) / ¡Pruébalo! (ast) / Prova-ho! (ca) / Es kann versucht werden! (de-ch) / Ceisio! (cy) / Try it! (en-gb) / Փորձի՛ր (hy) / 试一试! (zh) / Prøv det! (da) / Deneyin! (tr) / 試す! (ja) / Testa! (sv) / Versuchen Sie es! (de-formal) / 試一試! (zh-hant) / Versuche es! (de) / Kokeile! (fi) / Δοκιμάστε το! (el) / Provu ĝin! (eo) / Zkuste to! (cs) / Isprobajte! (bs) / Provalo! (it) / এটি চেষ্টা করে দেখুন! (bn) / Essayez ! (fr) / پرشن کرو (pnb) / Паспрабуйце! (be-tarask) / de-at (1) / Виконати! (uk) / לנסות את זה! (he) / SPARQL 쿼리 실행하기 (ko) / Biceribîne! (ku) / Probeer! (nl) / Experimenta! (pt) / ਪ੍ਰਸ਼ਨ ਕਰੋ (pa) / Izmēģini! (lv) / Prøv sjølv (nn) / Испробајте! (sr) / Cobalah! (id) / Пробајте! (mk) / Experimente! (pt-br) / جالنکن! (ms-arab) / ทดลองใช้ (th) / Wypróbuj! (pl) / Prøv selv! (nb) / 試試看! (zh-tw) / Jalankan! (ms) / Încercați! (ro) / Выполнить запрос (ru) / Provoje (sq) / Try it! (en) / تجربة! (ar) / 试一试! (zh-hans) / Оскалтэ! (udm)
{{SPARQL|embedded=yes|query=
#defaultView:Map
SELECT DISTINCT ?airport ?coor WHERE {
  ?airport (wdt:P31/wdt:P279) wd:Q62447; wdt:P17 wd:Q142.
    ?airport     wdt:P625 ?coor.
  MINUS { ?airport (wdt:P576|wdt:P582|wdt:P3999) ?dispar. }
  MINUS {
    ?airport wdt:P5817 ?interdit.
    VALUES ?interdit {
      wd:Q811683
      wd:Q63065035
      wd:Q12377751
      wd:Q30108381
      wd:Q11639308
    } 
  }
} |qlever=true }}
#defaultView:Map
SELECT DISTINCT ?airport ?coor WHERE {
  ?airport (wdt:P31/wdt:P279) wd:Q62447; wdt:P17 wd:Q142.
    ?airport     wdt:P625 ?coor.
  MINUS { ?airport (wdt:P576|wdt:P582|wdt:P3999) ?dispar. }
  MINUS {
    ?airport wdt:P5817 ?interdit.
    VALUES ?interdit {
      wd:Q811683
      wd:Q63065035
      wd:Q12377751
      wd:Q30108381
      wd:Q11639308
    } 
  }
}
¡Pruébalo! (es) / Próbáld ki! (hu) / ¡Pruébalo! (ast) / Prova-ho! (ca) / Es kann versucht werden! (de-ch) / Ceisio! (cy) / Try it! (en-gb) / Փորձի՛ր (hy) / 试一试! (zh) / Prøv det! (da) / Deneyin! (tr) / 試す! (ja) / Testa! (sv) / Versuchen Sie es! (de-formal) / 試一試! (zh-hant) / Versuche es! (de) / Kokeile! (fi) / Δοκιμάστε το! (el) / Provu ĝin! (eo) / Zkuste to! (cs) / Isprobajte! (bs) / Provalo! (it) / এটি চেষ্টা করে দেখুন! (bn) / Essayez ! (fr) / پرشن کرو (pnb) / Паспрабуйце! (be-tarask) / de-at (1) / Виконати! (uk) / לנסות את זה! (he) / SPARQL 쿼리 실행하기 (ko) / Biceribîne! (ku) / Probeer! (nl) / Experimenta! (pt) / ਪ੍ਰਸ਼ਨ ਕਰੋ (pa) / Izmēģini! (lv) / Prøv sjølv (nn) / Испробајте! (sr) / Cobalah! (id) / Пробајте! (mk) / Experimente! (pt-br) / جالنکن! (ms-arab) / ทดลองใช้ (th) / Wypróbuj! (pl) / Prøv selv! (nb) / 試試看! (zh-tw) / Jalankan! (ms) / Încercați! (ro) / Выполнить запрос (ru) / Provoje (sq) / Try it! (en) / تجربة! (ar) / 试一试! (zh-hans) / Оскалтэ! (udm) (QLever)
{{SPARQL|embedded=yes|query=
#defaultView:Map
SELECT DISTINCT ?airport ?coor WHERE {
  ?airport (wdt:P31/wdt:P279) wd:Q62447; wdt:P17 wd:Q142.
    ?airport     wdt:P625 ?coor.
  MINUS { ?airport (wdt:P576|wdt:P582|wdt:P3999) ?dispar. }
  MINUS {
    ?airport wdt:P5817 ?interdit.
    VALUES ?interdit {
      wd:Q811683
      wd:Q63065035
      wd:Q12377751
      wd:Q30108381
      wd:Q11639308
    } 
  }
} |qlever=true }}
#defaultView:Map
SELECT DISTINCT ?airport ?coor WHERE {
  ?airport (wdt:P31/wdt:P279) wd:Q62447; wdt:P17 wd:Q142.
    ?airport     wdt:P625 ?coor.
  MINUS { ?airport (wdt:P576|wdt:P582|wdt:P3999) ?dispar. }
  MINUS {
    ?airport wdt:P5817 ?interdit.
    VALUES ?interdit {
      wd:Q811683
      wd:Q63065035
      wd:Q12377751
      wd:Q30108381
      wd:Q11639308
    } 
  }
}
¡Pruébalo! (es) / Próbáld ki! (hu) / ¡Pruébalo! (ast) / Prova-ho! (ca) / Es kann versucht werden! (de-ch) / Ceisio! (cy) / Try it! (en-gb) / Փորձի՛ր (hy) / 试一试! (zh) / Prøv det! (da) / Deneyin! (tr) / 試す! (ja) / Testa! (sv) / Versuchen Sie es! (de-formal) / 試一試! (zh-hant) / Versuche es! (de) / Kokeile! (fi) / Δοκιμάστε το! (el) / Provu ĝin! (eo) / Zkuste to! (cs) / Isprobajte! (bs) / Provalo! (it) / এটি চেষ্টা করে দেখুন! (bn) / Essayez ! (fr) / پرشن کرو (pnb) / Паспрабуйце! (be-tarask) / de-at (1) / Виконати! (uk) / לנסות את זה! (he) / SPARQL 쿼리 실행하기 (ko) / Biceribîne! (ku) / Probeer! (nl) / Experimenta! (pt) / ਪ੍ਰਸ਼ਨ ਕਰੋ (pa) / Izmēģini! (lv) / Prøv sjølv (nn) / Испробајте! (sr) / Cobalah! (id) / Пробајте! (mk) / Experimente! (pt-br) / جالنکن! (ms-arab) / ทดลองใช้ (th) / Wypróbuj! (pl) / Prøv selv! (nb) / 試試看! (zh-tw) / Jalankan! (ms) / Încercați! (ro) / Выполнить запрос (ru) / Provoje (sq) / Try it! (en) / تجربة! (ar) / 试一试! (zh-hans) / Оскалтэ! (udm) (Orb Open Graph)
{{sparql|query=
SELECT ?titre (CONCAT(COALESCE(?auteur1, ""), ", ", COALESCE(?auteur3, "")) AS ?auteurs) ?année ?item WHERE {
?item wdt:P1433 wd:Q133575663 ; 
      wdt:P577 ?date.  
OPTIONAL {?item wdt:P2093 ?auteur1 ; 
                wdt:P50 ?auteur2 .}
BIND (year(?date) as ?année)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
                         ?item rdfs:label ?titre. 
                         ?auteur2 rdfs:label ?auteur3.
                       }
}
GROUP BY ?titre ?année ?auteur1 ?auteur3 ?item
|scholarly=true}}
SELECT ?titre (CONCAT(COALESCE(?auteur1, ""), ", ", COALESCE(?auteur3, "")) AS ?auteurs) ?année ?item WHERE {
?item wdt:P1433 wd:Q133575663 ; 
      wdt:P577 ?date.  
OPTIONAL {?item wdt:P2093 ?auteur1 ; 
                wdt:P50 ?auteur2 .}
BIND (year(?date) as ?année)
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". 
                         ?item rdfs:label ?titre. 
                         ?auteur2 rdfs:label ?auteur3.
                       }
}
GROUP BY ?titre ?année ?auteur1 ?auteur3 ?item
¡Pruébalo! (es) / Próbáld ki! (hu) / ¡Pruébalo! (ast) / Prova-ho! (ca) / Es kann versucht werden! (de-ch) / Ceisio! (cy) / Try it! (en-gb) / Փորձի՛ր (hy) / 试一试! (zh) / Prøv det! (da) / Deneyin! (tr) / 試す! (ja) / Testa! (sv) / Versuchen Sie es! (de-formal) / 試一試! (zh-hant) / Versuche es! (de) / Kokeile! (fi) / Δοκιμάστε το! (el) / Provu ĝin! (eo) / Zkuste to! (cs) / Isprobajte! (bs) / Provalo! (it) / এটি চেষ্টা করে দেখুন! (bn) / Essayez ! (fr) / پرشن کرو (pnb) / Паспрабуйце! (be-tarask) / de-at (1) / Виконати! (uk) / לנסות את זה! (he) / SPARQL 쿼리 실행하기 (ko) / Biceribîne! (ku) / Probeer! (nl) / Experimenta! (pt) / ਪ੍ਰਸ਼ਨ ਕਰੋ (pa) / Izmēģini! (lv) / Prøv sjølv (nn) / Испробајте! (sr) / Cobalah! (id) / Пробајте! (mk) / Experimente! (pt-br) / جالنکن! (ms-arab) / ทดลองใช้ (th) / Wypróbuj! (pl) / Prøv selv! (nb) / 試試看! (zh-tw) / Jalankan! (ms) / Încercați! (ro) / Выполнить запрос (ru) / Provoje (sq) / Try it! (en) / تجربة! (ar) / 试一试! (zh-hans) / Оскалтэ! (udm) (query-scholarly)

⧼wm-commonstrings-seealso⧽

Warning: If you use the pipe character ("|") in your query, you need to replace it with {{!}}

  • {{SPARQLText}} syntax highlighted query text
  • {{SPARQL}} shows query text, links to the non-executed query (this template)
  • {{SPARQL2}} with item/property listing
  • {{SPARQL5}} with item/property listing
  • {{SPARQL6}} with item/property listing, indentable
  • {{SPARQL8}} inline (no query text), links to the non-executed query
  • {{SPARQL9}} same as SPARQL?
  • {{SPARQL Inline}} inline (no query text), links to the non-executed query and or the results page
  • {{SPARQL Box}} inline (no query text) styled as a centered paragraph box, links to the non-executed query
  • {{Wdquery}} inline (no query text), links to the non-executed query, rather than to the results page
  • {{Quickquery}} simple graph patterns, allows to set limit and defaultView
  • {{Query page}} query stored on a dedicated wiki page, to be transcluded into other pages