Difference between revisions of "Template:SPARQL"
Line 1: | Line 1: | ||
<onlyinclude><div {{#switch: {{{state|}}} | collapsed = class="mw-collapsible mw-collapsed" | expanded = class="mw-collapsible" }} >{{#tag:syntaxhighlight|{{SPARQLText|p={{{p|}}}|q={{{q|}}}|v={{{v|}}}|query={{#invoke:ConcatArgs|ConcatArgs|init=query|min=1}}|extraprefix={{{extraprefix|}}} }}|lang="sparql"}}</div> | <onlyinclude><div {{#switch: {{{state|}}} | collapsed = class="mw-collapsible mw-collapsed" | expanded = class="mw-collapsible" }} >{{#tag:syntaxhighlight|{{SPARQLText|p={{{p|}}}|q={{{q|}}}|v={{{v|}}}|query={{#invoke:ConcatArgs|ConcatArgs|init=query|min=1}}|extraprefix={{{extraprefix|}}} }}|lang="sparql"}}</div> | ||
− | [{{#switch:{{{project|wd}}}|wd=//query.personaldata.io/|sdc=//sdcquery.wmflabs.org}}#{{urlencode: {{SPARQLText|p={{{p|}}}|q={{{q|}}}|v={{{v|}}}|query={{#invoke:ConcatArgs|ConcatArgs|init=query|min=1}}|extraprefix={{{extraprefix|}}} }} | PATH }} {{{label|{{int try it}}}}}] | + | [{{#switch:{{{project|wd}}}|wd=//query.personaldata.io/|sdc=//sdcquery.wmflabs.org}}#{{urlencode: {{SPARQLText|p={{{p|}}}|q={{{q|}}}|v={{{v|}}}|query={{#invoke:ConcatArgs|ConcatArgs|init=query|min=1}}|extraprefix={{{extraprefix|}}} }} | PATH }} {{{label|{{int try it}}}}}] ([{{#switch:{{{project|wd}}}|wd=//query.personaldata.io/embed.html|sdc=//sdcquery.wmflabs.org}}#{{urlencode: {{SPARQLText|p={{{p|}}}|q={{{q|}}}|v={{{v|}}}|query={{#invoke:ConcatArgs|ConcatArgs|init=query|min=1}}|extraprefix={{{extraprefix|}}} }} | PATH }} embedded]) |
− | |||
− | [{{#switch:{{{project|wd}}}|wd=//query.personaldata.io/embed.html|sdc=//sdcquery.wmflabs.org}}#{{urlencode: {{SPARQLText|p={{{p|}}}|q={{{q|}}}|v={{{v|}}}|query={{#invoke:ConcatArgs|ConcatArgs|init=query|min=1}}|extraprefix={{{extraprefix|}}} }} | PATH }} | ||
</onlyinclude> | </onlyinclude> | ||
{{documentation}} | {{documentation}} |
Latest revision as of 08:11, 19 December 2019
PREFIX pdio: <https://wiki.personaldata.io/entity/>
PREFIX pdiot: <https://wiki.personaldata.io/prop/direct/>
PREFIX pdiop: <https://wiki.personaldata.io/prop/>
PREFIX pdiops: <https://wiki.personaldata.io/prop/statement/>
PREFIX pdiopq: <https://wiki.personaldata.io/prop/qualifier/>
Usage
<templatedata> { "params": { "p": { "label": "p", "description": "Produce p: prefix if set", "type": "boolean" }, "q": { "label": "q", "description": "Produce q: prefix if set", "type": "boolean" }, "v": { "label": "v", "description": "Produce v: prefix if set", "type": "boolean" }, "query": { "required": true, "label": "query", "description": "SPARQL query", "example": "SELECT * WHERE { ?x wdt:P31 wd:Q5 } LIMIT 1", "type": "string" }, "extraprefix": { "description": "Extra prefixes to be added", "example": "PREFIX wikibase: <http://wikiba.se/ontology#>", "type": "string" }, "state": { "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.", "type": "string" }, "label": { "description": "Text to be used as the label of the link to the Wikidata Query Service", "type": "content", "default": "Try it!" }, "shortURL": { "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", "type": "string" } }, "description": "This template displays SPARQL query with syntax highlighting, prefixes and link to WDQS beta site to run the query. ", "paramOrder": [ "query", "p", "q", "v", "extraprefix", "state", "label", "shortURL" ] } </templatedata>
Esempi (it) / উদাহরণসমূহ (bn) / Exemples (fr) / Vuesiehtimmieh (sma) / Beispiele (de) / Примеры (ru) / Примери (mk) / Engreifftiau (cy) / Exemplos (pt) / Shembuj (sq) / أمثلة (ar) / Døme (nn) / Eksempler (da) / 용례들 (ko) / 例 (ja) / Exemplos (pt-br) / Példák (hu) / exempel (sv) / Mifano (sw) / Приклади (uk) / Voorbeelden (nl) / 範例 (zh-hant) / Contoh (id) / Eksempler (nb) / Ovdamearkkat (se) / Examples (en) / Ekzemploj (eo) / 示例 (zh-hans) / Примери (sr)
- {{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}}
PREFIX pdio: <https://wiki.personaldata.io/entity/>
PREFIX pdiot: <https://wiki.personaldata.io/prop/direct/>
PREFIX pdiop: <https://wiki.personaldata.io/prop/>
PREFIX pdiops: <https://wiki.personaldata.io/prop/statement/>
PREFIX pdiopq: <https://wiki.personaldata.io/prop/qualifier/>
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
Template:Int See also
- Wikidata:SPARQL query service
{{Wdquery}}
- WDQ
The above documentation is transcluded from Template:SPARQL/doc. (edit | history) Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages. Please add categories to the /doc subpage. Subpages of this template. |