On 14/03/12 15:49, Svatopluk Šperka wrote:
Hi all,
could someone give me an advice on how to correctly construct a SPARQL 1.1 query
containing "FILTER NOT EXISTS" construct ?
What I've found in the ARQ documentation is that ElementFilter takes an Expr in the
constructor but ElementNotExists is not a subclass of Expr. So far I've used E_NotExists
with ElementFilter but it generates "FILTER notexists" which is not correct
syntax. TDB accepts it but I'm experimenting with Stardog for performance reasons and it
throws a MalformedQuery exception so I would need to generate a correct syntax.
ElementNotExists is for a ARQ/SPARQL extension not requiring the keyword
FILTER
SELECT *
{
?s ?p ?o
NOT EXISTS { ?s ?p ?o }
}
otherwise you need to use the expression form in E_NotExists with
ElementFilter.
Generally, constructing SPARQL algebra is easier. See OpToQuery to get
synatx out.
The SPARQL grammar rule is:
[118] NotExistsFunc ::= 'NOT' 'EXISTS' GroupGraphPattern
so 'notexists' is legal SPARQL (keywiords are case insensitive) as there
is no requirement for white space between tokens.
Andy
Thanks in advance.
Svatopluk Šperka