:Document_1
a owms:Document ;
owms:subject sc:BasisonderwijsEnSpeciaalOnderwijs .
Prefix sc standing for: "http://www.test.be/vocab/sc/"
:Document_2
a owms:Document ;
owms:subject vsr:Basisonderwijs ;
Prefix vsr standing for: "http://www.test.be/vocab/vsr/"
sc:BasisonderwijsEnSpeciaalOnderwijsNow the idea was to construct two new properties:
a skos:Concept ;
skos:prefLabel "Basisonderwijs en Speciaal Onderwijs"^^xsd:string ;
Or another example graphically depicted using Topbraid Composer.
We start our SPARQL ConstructCONSTRUCT { ?subject vsr:subject ?value.}
WHERE { ?subject owms:subject ?object.
?object skos:prefLabel ?value ......
BUT only if ?object belongs to the vsr namespace. So we need a FILTER construct to constrain the tripples we want to work on.
SPARQL itself doesn't offer a function to test on namespaces. Luckily there is the JENA ARQ function libary that offers us this functionality.
| URL: | afn:namespace |
| Description: | Returns the namespace of a URI resource. Based on splitting the IRI, not on any prefixes in the query or dataset. For example, the namespace of http://test.com/my#Example is http://test.com/my#. |
| Arguments: |
|
| Returns: | xsd:string |
So our SPARQL construct becomes:
CONSTRUCT { ?subject vsr:subject ?value.}
WHERE { ?subject owms:subject ?object.
?object skos:prefLabel ?value
FILTER (afn:namespace(?object) = 'http://www.test.be/vocab/vsr/' ).}
One of the available datasources on the web is DBPedia.
Let's take a look at what data are available for the city of Hasselt, Belgium.
![]()
You see that several propertyvalues such as for abstract are available in several languages. I'm only interested in the Dutch entries.
Using the following SPARQL SELECT in SPARQL Explorer for http://dbpedia.org/sparql
SELECT * WHERE {
<http://dbpedia.org/resource/Hasselt> rdfs:label ?label;
dbpedia2:abstract ?abstract.
}
leads to
SELECT * WHERE {
<http://dbpedia.org/resource/Hasselt> rdfs:label ?label;
dbpedia2:abstract ?abstract
FILTER (lang(?label) = 'nl')
FILTER (lang(?abstract) = 'nl').
}
gives us what we want.
![]()
Comments