Mallineen ohje [näytä] [muokkaa] [päivitä]


Parametrit muokkaa

This template displays SPARQL query with syntax highlighting, prefixes and link to WDQS beta site to run the query.

Mallineen parametrit[Hallitse TemplateDataa]

ParametriKuvausTyyppiTila
queryquery

SPARQL query

Esimerkki
SELECT * WHERE { ?x wdt:P31 wd:Q5 } LIMIT 1
Merkkijonopakollinen
pp

Produce p: prefix if set

Totuusarvovalinnainen
qq

Produce q: prefix if set

Totuusarvovalinnainen
vv

Produce v: prefix if set

Totuusarvovalinnainen
extraprefixextraprefix

Extra prefixes to be added

Esimerkki
PREFIX wikibase: <http://wikiba.se/ontology#>
Merkkijonovalinnainen
endpointendpoint

linkki sivulle jolla haku tehdään

URLvalinnainen
projectproject

Projekti-alias eri SPARQL-endpointeille, endpoint-ohittaa tämän

Oletus
wd
Esimerkki
wd, sdc, osm
Merkkijonovalinnainen

Esimerkit muokkaa

Wikidata muokkaa

{{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
}}
Tulostus
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
Kokeile

Structure data on Commons muokkaa

Haetaan kuvat joissa on esitettynä Douglas Adams

  • {{SPARQL|project=sdc|query=SELECT ?file WHERE { ?file wdt:P180 wd:Q42 . } }}
#Depictions of Douglas Adams
#shows M-entities that depict Douglas Adams

SELECT ?file WHERE { 
   ?file wdt:P180 wd:Q42 . 
}
Kokeile

OpenStreetMap (Sophox) muokkaa

Kysely Sophoxilla:lla käyttäen endpoint-parametria.

  • {{SPARQL|endpoint=https://sophox.org/#|query= PREFIX wdt: <http://www.wikidata.org/prop/direct/> ... }}
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikidata: <https://query.wikidata.org/bigdata/namespace/wdq/sparql>
SELECT * WHERE {
  SERVICE wikidata:
  {
  	wd:Q465687 wdt:P2180 ?kansallisbiografiatunniste .  
  }
}
LIMIT 1
Kokeile

Tai sama käyttäen project-parametria

  • {{SPARQL|project=osm|query= PREFIX wdt: <http://www.wikidata.org/prop/direct/> ... }}
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikidata: <https://query.wikidata.org/bigdata/namespace/wdq/sparql>
SELECT * WHERE {
  SERVICE wikidata:
  {
  	wd:Q465687 wdt:P2180 ?kansallisbiografiatunniste .  
  }
}
LIMIT 1
Kokeile


Muut muokkaa

Kysely Yasqui:lla Fintosta

  • {{SPARQL|endpoint=http://yasgui.org/#endpoint=http://api.finto.fi/sparql&query=|query= PREFIX wdt: <http://www.wikidata.org/prop/direct/> ... }}
prefix taxmeon: <http://www.yso.fi/onto/taxmeon/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?higherScifiLabel ?scifiLabel ?taxonRank
WHERE {
  ?scifi taxmeon:hasVernacularName <http://www.yso.fi/onto/kassu/k20487> ;
         rdfs:label ?scifiLabel ;
         a ?taxonRank ;
  FILTER (regex(str(?taxonRank), 'http://www.yso.fi/onto/taxonomic-ranks/')) .
  OPTIONAL { ?scifi taxmeon:isPartOfHigherTaxon/rdfs:label ?higherScifiLabel }
}
Kokeile

Kysely Yasqui:lla sparql.europeana.eu:rajapintaa vasten

  • {{SPARQL|endpoint=http://yasgui.org/#endpoint=http://sparql.europeana.eu/&query=|query= PREFIX wdt: <http://www.wikidata.org/prop/direct/> ... }}
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wikidata: <https://query.wikidata.org/bigdata/namespace/wdq/sparql>
SELECT * WHERE {
  SERVICE wikidata:
  {
  	wd:Q465687 wdt:P2180 ?kansallisbiografiatunniste .  
  }
}
LIMIT 1
Kokeile

Katso myös muokkaa

Kokeile