!!! Listings zum Artikel
!!! Funkenschlag: SPARQL -- Anfragesprache für RDF-Daten
!!! von Stefan Minter und Bastian Spanneberg
!!! iX 1/08, S. 134
!!! Listing 1: Simple Anfrage/Ergebnis
PREFIX dc:
SELECT ?urheber
WHERE
{
?urheber .
}
!!! Linie ziehen
http://www.example.org/staffid/85740
!!! Listing 2: Komplexere Anfrage/Ergebnis
PREFIX smwCat:
PREFIX smwProp:
PREFIX rdf:
SELECT ?city ?country ?population ?geoLocation
WHERE {
?city rdf:type smwCat:City.
?city smwProp:Located_in ?country.
?city smwProp:Population ?population.
?city smwProp:Coordinates ?geoLocation.
}
!!! Linie ziehen
http://ontoworld.org/wiki/Special:URIResolver/Berlin
http://ontoworld.org/wiki/Special:URIResolver/Germany
3391407
52°31'0?N, 13°24'0?E
...
!!! Listing 3: UNION
SELECT ?subject ?ingoingPredicate ?outgoingPredicate ?object
WHERE {
{
?subject ?ingoingPredicate
.
} UNION {
?outgoingPredicate ?object.
}
}
!!! Linie ziehen
true
!!! Listing 4: ASK
PREFIX smwCat:
PREFIX smwProp:
PREFIX rdf:
ASK {
?city rdf:type smwCat:City.
?city smwProp:Population ?population.
FILTER ( ?population > 1000000 )
}
!!! Listing 5: CONSTRUCT
PREFIX smwCat:
PREFIX smwProp:
PREFIX rdf:
PREFIX ex:
CONSTRUCT {
?city rdf:type ex:Stadt.
?city ex:istTeilVon ?country.
?city ex:hatEinwohnerZahl ?population.
}
WHERE {
?city rdf:type smwCat:City.
?city smwProp:Located_in ?country.
?city smwProp:Population ?population.
}
!!! Listing 6: DESCRIBE
PREFIX smwCat:
PREFIX rdf:
DESCRIBE ?x
WHERE {
?x rdf:type smwCat:City.
}
!!! Listing 7: Joseki-Konfiguration
@prefix swivt: .
@prefix smwCat: .
@prefix wiki: .
@prefix obowl: .
@prefix rdfs: .
@prefix rdf: .
@prefix foaf: .
@prefix : .
@prefix owl: .
wiki:Halle_-28Saale-29
a swivt:Subject , smwCat:City ;
rdfs:isDefinedBy
;
rdfs:label "Halle (Saale)" ;
wiki:Property-3AAdjacent_to
wiki:Saale ;
wiki:Property-3AArea-23m-C2-B2
"135000000"^^ ;
wiki:Property-3ALocated_in
wiki:Germany , wiki:Saxony-2DAnhalt ;
wiki:Property-3APopulation
"240000"^^ ;
swivt:page .
...
!!! Listing 8: joseki-config.ttl
## This file is written in N3 / Turtle
@prefix rdfs: .
@prefix rdf: .
@prefix xsd: .
@prefix module: .
@prefix joseki: .
@prefix ja: .
## About this configuration
<> rdfs:label "Joseki Configuration File" .
## About this server
[] rdf:type joseki:Server ;
joseki:initialization
[ module:implementation
[ module:className ;
rdfs:label "Example initializer" ; ]
] ;
.
## Service 1 - SPARQL processor for the ontoworld dataset
[] rdf:type joseki:Service ;
rdfs:label "SPARQL service for the ontoworld model" ;
joseki:serviceRef "books" ;
joseki:dataset _:ix ;
joseki:processor joseki:ProcessorSPARQL_FixedDS ;
.
## Datasets
_:ix rdf:type ja:RDFDataset ;
ja:defaultGraph _:ixModel ;
rdfs:label "DBMS iX Dataset" ;
.
## Models
_:ixModel rdf:type ja:RDBModel ;
rdfs:label "iX SPARQL" ;
ja:connection
[
ja:dbType "MySQL" ;
ja:dbURL "jdbc:mysql://localhost:3306/jena" ;
ja:dbUser "dbUser" ;
ja:dbPassword "dbPassword" ;
ja:dbClass "com.mysql.jdbc.Driver" ;
] ;
ja:modelName "ix"
.
## Processors
joseki:ProcessorSPARQL_FixedDS
rdfs:label "SPARQL processor for fixed datasets" ;
rdf:type joseki:Processor ;
module:implementation joseki:ImplSPARQL ;
# This processor does not accept queries with FROM/FROM NAMED
joseki:allowExplicitDataset "false"^^xsd:boolean ;
joseki:allowWebLoading "false"^^xsd:boolean ;
joseki:lockingPolicy joseki:lockingPolicyMRSW ;
.
joseki:ImplSPARQL
rdf:type joseki:ServiceImpl ;
module:className .