Predefinição:SPARQL/doc
| Ficheiro:Edit-copy green.svg | Predefinição:Documentation subpage/text/en |
Utilização
Esta predefinição ilustra pedidos (queries) SPARQL com realce de sintaxe, prefixos e ligações para o sítio beta WDQS, que correrá o pedido.
| Parâmetro | Descrição | Tipo | Estado | |
|---|---|---|---|---|
| p | p | Produce p: prefix if set | Booliano | opcional |
| q | q | Produce q: prefix if set | Booliano | opcional |
| v | v | Produce v: prefix if set | Booliano | opcional |
| query | query | SPARQL query | String | obrigatório |
extraprefix | Extra prefixes to be added | String | opcional | |
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 | opcional | |
label | Text to be used as the label of the link to the Wikidata Query Service
| Conteúdo | opcional | |
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 | opcional | |
| project | project | project name: '''wd''' for Wikidata and '''sdc''' for Structured Data on Commons | String | opcional |
| Embedded | embedded | Shall the link direct user to the results (yes) or to the code (no, empty) | String | recomendado |
Exemplos
- Wikicode:
{{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}}
- Rendered result:
<templatestyles src="SPARQL/styles.css" />
?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</syntaxhighlight>- Wikicode:
{{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
}
}
} }}
- Rendered result:
<templatestyles src="SPARQL/styles.css" />
- 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
}
}
}</syntaxhighlight>Erro de comando: Não existe nenhum módulo "TranslateThis".