# SPARQL UPDATE query to search for SPARQL endpoints # results are stored in named graph # start with: # INSERT DATA { graph { # "todo" # }} # repeat query until triple "todo" does not occur WITH DELETE { ?ep "todo" } INSERT { ?ep "done". ?ep ?status. ?ep3 "todo". } WHERE { select distinct ?ep ?status (if(EXISTS { ?ep2 ?any },0,?ep2) as ?ep3) where { # we have to select ?p and ?ep1 here due to a Jena bug select ?ep ?p (if(bound(?p),"access","no access") as ?status) ?ep1 (IRI(?ep1) as ?ep2) where { ?ep "todo" # without optional, ?ep is not bound in case of federated query failure # https://issues.apache.org/jira/browse/JENA-552 OPTIONAL { # check service availability SERVICE SILENT ?ep { select ?p where { { ?s ?p ?o } UNION { GRAPH ?g1 { ?s ?p ?o } } } limit 1 } # no result instead of emtpy result needed if service fails, otherwise ?ep will not be bound # https://issues.apache.org/jira/browse/JENA-552 FILTER(bound(?p)) # ask the service for sparql endpoints # without OPTIONAL, ?p would not be bound in case the endpoint works but has nothing new OPTIONAL { SERVICE SILENT ?ep { select distinct ?ep1 where { { ?s1 ?ep1 } UNION { GRAPH ?g { ?s1 ?ep1 } } } } FILTER(bound(?ep1)) } } } } }