Template:SPARQL/doc

From MaRDI portal

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 and sdc for Structured Data on Commons" }, "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" } }, "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) / 용례들 (ko) / Ekzemploj (eo) / Примери (mk) / Esempi (it) / উদাহরণসমূহ (bn) / Exemples (fr) / Прыклады (be-tarask) / Ví dụ (vi) / Beispiele (de) / Παραδείγματα (el) / Contoh (id) / Примери (sr) / Examples (en-gb) / Mînak (ku) / Exemplos (pt-br) / چونتوه (ms-arab) / ตัวอย่าง (th) / Mifano (sw) / Eksempler (nb) / Voorbeelden (nl) / Примеры (ru) / Ovdamearkkat (se) / Døme (nn) / Exemplos (pt) / 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
Try it! (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
    } 
  }
}
Try it!

Véase también (es) / Lásd még (hu) / vegeu també (ca) / Siehe auch (de) / See also (en-gb) / Se også (da) / Ayrıca bakınız (tr) / 参照 (ja) / se även (sv) / Див. також (uk) / 參見 (zh-hant) / 같이 보기 (ko) / Vidu ankaŭ (eo) / Související (cs) / Vedi anche (it) / আরও দেখুন (bn) / Voir aussi (fr) / Глядзіце таксама (be-tarask) / Ver também (pt) / Поврзано (mk) / Видети још (sr) / Δείτε επίσης (el) / Lihat pula (id) / Озьы ик учке (udm) / ਹੋਰ ਵੇਖੋ (pa) / ดูเพิ่ม (th) / Sjå òg (nn) / Se også (nb) / Zie ook (nl) / Zobacz też (pl) / См. также (ru) / Shih edhe (sq) / védarse anca (vec) / See also (en) / انظر أيضا (ar) / 参见 (zh-hans) / ہور ویکھو (pnb)

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 patters, allows to set limit and defaultView
  • {{Query page}} query stored on a dedicated wiki page, to be transcluded into other pages