We provide here a collection of SPARQL transformers for covering common export needs.
Realizing the export of a scheme might not be so straightforward: an RDF thesaurus could contain a lot of specific RDF constructs defined by the community (e.g. developed by means of Custom Forms) maintaining the thesaurus and not all of them might be local to scheme, so there is no way to make a general exporter that works for all thesauri. The following SPARQL code performs general operations that will probably satisfy the need of most thesauri, plus it can represent a starting point for developing a custom exporter for your own thesaurus.
PREFIX skos: <http://www.w3.org/2004/02/skos/core#>
PREFIX skosxl: <http://www.w3.org/2008/05/skos-xl#>
DELETE {
?concept ?p ?o .
?label ?pLabel ?oLabel .
?scheme ?pScheme ?oScheme .
}
WHERE{
?concept a skos:Concept .
FILTER NOT EXISTS{
?concept skos:inScheme|skos:topConceptOf|^skos:hasTopConcept <TARGET_SCHEME> .
}
?concept ?p ?o .
OPTIONAL {
?concept ?p2 ?label .
?label a skosxl:Label .
?label ?pLabel ?oLabel .
}
?scheme a skos:ConceptScheme .
FILTER (?scheme != <TARGET_SCHEME>)
?scheme ?pScheme ?oScheme .
OPTIONAL{
?scheme ?p3 ?labelScheme .
?labelScheme a skosxl:Label .
?labelScheme ?pLabelScheme ?oLabelScheme .
}
}
So, this generic UPDATE removes from the export:
A further possibility is to remove all triples with the skos:Concepts and skosxl:Labels not belonging to the selected scheme as their object. With the sparql update above, in case of two schemes A and B where A is the scheme to be exported, triples such as:
:CA skos:related CB
where CB belongs to scheme B, would not be removed (CB would be a “mention” in the resulting dataset).