I'm trying to create a graph with all the related predicates and objects. To illustrate, I have the instance ex:First_Civil_War and now I want all predicates and objects to be shown in the graph. I have done this in the following way.
construct {
} where {
ex:Fourth_Conquest_of_Gaul ?p ?o
} limit 100
However, I want to exclude some of the predicates, for example ex:hasActor. How would I go about this, as the OPTIONAL statement does not work within a CONSTRUCT query.
OPTIONALnot work? You can put any SPARQL query into theWHEREpart. I also don't see howOPTIONALis used to exclude triples, that would be more the task of aFILTERCONSTRUCT {}so it returns the empty graph. Put in the triple patterns you want returned - but not the word OPTIONAL. You can add triple patterns with variables used in an OPTIONAL clause in the WHERE part. The triple template is skipped if a variable is unbound.