On Mon, Aug 5, 2013 at 9:02 AM, Igor Brussilowski
<[email protected]> wrote:
> Hi all,
>
> I'm looking for how to access list items in a reasoner rule. E.g the pattern 
> (?S owl:kasKey ?L) returns a list of all matching objects. Is there any way 
> to access here the elements of the list for further processing, e.g. to print 
> them all out?

According to the documentation [1], there are a number of builtins for
working with lists:

listContains(?l, ?x)
listNotContains(?l, ?x) 
Passes if ?l is a list which contains (does not contain) the element
?x, both arguments must be ground, can not be used as a generator.

listEntry(?list, ?index, ?val)  
Binds ?val to the ?index'th entry in the RDF list ?list. If there is
no such entry the variable will be unbound and the call will fail.
Only useable in rule bodies.

listLength(?l, ?len)    
Binds ?len to the length of the list ?l.

listEqual(?la, ?lb)
listNotEqual(?la, ?lb)  
listEqual tests if the two arguments are both lists and contain the
same elements. The equality test is semantic equality on literals
(sameValueAs) but will not take into account owl:sameAs aliases.
listNotEqual is the negation of this (passes if listEqual fails).

listMapAsObject(?s, ?p ?l)
listMapAsSubject(?l, ?p, ?o)    
These can only be used as actions in the head of a rule. They deduce a
set of triples derived from the list argument ?l : listMapAsObject
asserts triples (?s ?p ?x) for each ?x in the list ?l,
listMapAsSubject asserts triples (?x ?p ?o).

[1] http://jena.apache.org/documentation/inference/#RULEbuiltins

-- 
Joshua Taylor, http://www.cs.rpi.edu/~tayloj/

Reply via email to