1# This is a test SPARQL query
2
3BASE <http://pygments.org/examples/sparql.rq>
4
5PREFIX foaf: <http://xmlns.com/foaf/0.1/>
6PREFIX ex: <http://example.org/>
7PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
8PREFIX dcterms: <http://purl.org/dc/terms/>
9
10SELECT ?person (COUNT(?nick) AS ?nickCount) {
11    <#jonny> foaf:knows ?person .
12    ?person a foaf:Person .
13    ?person foaf:firstName "Freddy" .
14    ?person foaf:lastName "Smith" .
15    # predicate-object list
16    ?person foaf:nick ?nick ;
17      foaf:age "21"^^xsd:int ; # typed literal
18      ex:title 'Mr' ; # single-quoted string
19      ex:width 2 ; # integer
20      ex:height 1.80 ; # float
21      ex:distanceToSun 1.4e8 ; # float with exponent
22      ex:ownsACat true ;
23      ex:catName "Kitty", "Kitty_" ; # object list
24      # some other float values
25      ex:float1 .125 ;
26      ex:float2 +2.5e10 ;
27      ex:float3 2.5e+10 ;
28      ex:float4 -1.e-10 ;
29      ex:float5 .0e1 ;
30      ex:float6 5e11 ;
31      ex:float7 1. ;
32      ex:aUnicodeÀExample "somestring" ;
33      ex:catName "Kitty", "Kitty_" ; # object list
34      ex:escape "\n\u00c0\U00010000";
35      ex:catAge ?catage ;
36      dcterms:description "Someone with a cat called \"cat\"."@en . # language tag
37    ?person foaf:knows _:b0 .
38    _:b0 foaf:knows [ _:b1 a foaf:Person; foaf:name "Jonny" . ] .
39    OPTIONAL { ?person foaf:isPrimaryTopicOf ?page }
40    OPTIONAL { ?person foaf:name ?name
41               { ?person foaf:depiction ?img }
42               UNION
43               { ?person foaf:firstName ?firstN } }
44    FILTER ( bound(?page) || bound(?img) || bound(?firstN) )
45    FILTER ( ?catage < 101 && ?catage > 9 && ?catage >= 10 && ?catage <= 100 && ?catage != 20 )
46}
47GROUP BY ?person
48ORDER BY ?img ASC(?firstN) DESC(?page)
49