Filtering out resources from a sequence that appear in another sequence

Hello,

Hoping for some help with troublesome query...

I have a number of resources that are related in a parent/child hierarchy.
I need to perform a query that identifies the other children of resources
belonging to an ancestor path. In other words if I have resource x then i
want to find x's aunt, great-aunt, great-great-aunt and so on, if they
exist (we are not talking about people here - I am only using the term aunt
to explain the relationship).

My resources have a property which identifies their parent resource (there
is only ever one parent) and I am using a SPARQL 1.1 property path to find
the ancestors, e.g.

?resource :parent+ ?ancestor .

I am then finding the immediate children of these ancestors as follows:

?child :parent ?ancestor .

...and I have confirmed that ?ancestor and ?child contain the exact
resources that I would expect. The final solution however requires me to
find all of the child resources that are not ancestors and this I cannot
get to work. I thought the answer would be simply be...

FILTER(?child != ?ancestor)

but this has no affect and ?child still contains duplicates of resources in
?ancestors.

For completeness the full query is attached. I am executing this query
against a Jena Fuseki SPARQL endpoint.

Thanks
Rob

-- 

Rob Walpole
Email robkwalpole@gmail.com
Tel. +44 (0)7969 869881
Skype: RobertWalpolehttp://www.linkedin.com/in/robwalpole

Received on Monday, 28 January 2013 12:57:04 UTC