Template:SPARQL
Usage
This template displays SPARQL query with syntax highlighting, prefixes and link to WDQS beta site to run the query.
Parameter | Description | Type | Status | |
---|---|---|---|---|
query | query | SPARQL query
| String | required |
p | p | Produce p: prefix if set | Boolean | optional |
q | q | Produce q: prefix if set | Boolean | optional |
v | v | Produce v: prefix if set | Boolean | optional |
Extraprefix | extraprefix | Extra prefixes to be added
| String | optional |
State | state | 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. | String | optional |
Label | label | Text to be used as the label of the link to the Wikidata Query Service
| Content | optional |
ShortURL | shortURL | slug of the query's short URL, as generated by the WMF URL shortener - for example, for https://w.wiki/37j enter just 37j | String | optional |
project | project | project name: '''wd''' for Wikidata and '''sdc''' for Structured Data on Commons | String | optional |
Examples
- {{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
See also
- Wikidata:SPARQL query service
{{SPARQL2}}
{{SPARQL Inline}}
{{Wdquery}}
- WDQ
Page Module:Message box/styles.css must have content model "Sanitized CSS" for TemplateStyles (current model is "CSS").
Template:Documentation/getText Template:Documentation/getText Template:Documentation/getText Template:Documentation/getText |