Skip to content

Instantly share code, notes, and snippets.

@wstrinz
Last active December 19, 2015 03:19
Show Gist options
  • Save wstrinz/5889227 to your computer and use it in GitHub Desktop.
Save wstrinz/5889227 to your computer and use it in GitHub Desktop.
Example files to test FILTER NOT EXISTS in RDF.rb
@prefix : <http://example.com/#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
:hr a :thing;
rdfs:label "Has Range"@en;
rdfs:range :somerange.
:nr a :thing;
rdfs:label "No Range"@en.
PREFIX : <http://example.com/#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?t WHERE {
?t a :thing
FILTER NOT EXISTS{?t rdfs:range ?r}
}
PREFIX : <http://example.com/#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?t WHERE {
?t a :thing
OPTIONAL {?t rdfs:range ?r}
FILTER (!bound(?r))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment