summaryrefslogtreecommitdiff
path: root/tests/examplefiles/sparql.rq
blob: d979d2033e6f27f48ca04aad64a9b1f1f0b50ddf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# This is a test SPARQL query

BASE <http://pygments.org/examples/sparql.rq>

PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX ex: <http://example.org/>
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX dcterms: <http://purl.org/dc/terms/>

SELECT ?person (COUNT(?nick) AS ?nickCount) {
    <#jonny> foaf:knows ?person .
    ?person a foaf:Person .
    ?person foaf:firstName "Freddy" .
    ?person foaf:lastName "Smith" .
    # predicate-object list
    ?person foaf:nick ?nick ;
      foaf:age "21"^^xsd:int ; # typed literal
      ex:title 'Mr' ; # single-quoted string
      ex:width 2 ; # integer
      ex:height 1.80 ; # float
      ex:distanceToSun 1.4e8 ; # float with exponent
      ex:ownsACat true ;
      ex:catName "Kitty", "Kitty_" ; # object list
      # some other float values
      ex:float1 .125 ;
      ex:float2 +2.5e10 ;
      ex:float3 2.5e+10 ;
      ex:float4 -1.e-10 ;
      ex:float5 .0e1 ;
      ex:float6 5e11 ;
      ex:float7 1. ;
      ex:aUnicodeÀExample "somestring" ;
      ex:catName "Kitty", "Kitty_" ; # object list
      ex:escape "\n\u00c0\U00010000";
      ex:catAge ?catage ;
      dcterms:description "Someone with a cat called \"cat\"."@en . # language tag
    ?person foaf:knows _:b0 .
    _:b0 foaf:knows [ _:b1 a foaf:Person; foaf:name "Jonny" . ] .
    OPTIONAL { ?person foaf:isPrimaryTopicOf ?page }
    OPTIONAL { ?person foaf:name ?name
               { ?person foaf:depiction ?img }
               UNION
               { ?person foaf:firstName ?firstN } }
    FILTER ( bound(?page) || bound(?img) || bound(?firstN) )
    FILTER ( ?catage < 101 && ?catage > 9 && ?catage >= 10 && ?catage <= 100 && ?catage != 20 )
} 
GROUP BY ?person 
ORDER BY ?img ASC(?firstN) DESC(?page)