I don't think that this is possible with the current implementation since a Function is supposed to return a single value and you'd need something that returns a set of values resp. bindings.
Have you checked SPARQL SPIN [1]? Maybe this is something you could use. [1] http://spinrdf.org/ > Hello, > > I have complex SPARQL queries, which I would like to divide into several > parts (like function definitions), in order to reuse these parts among > different SPARQL queries and in order to make a single SPARQL query easier to > understand. What are my options to achieve this? > > I had a look at Jenas built in functionality to support user defined function > definitions. The problem with them is that it seems that they can be used > only for simple functionality like calculating the max of two integers. But I > have quite complex functionality, which I don't want to rewrite in Java. > Example: > > ------------------------------------------------------------------------------------------------ > select * where { > ?s a ?tpe . > filter not exists { > ?sub rdfs:subClassOf ?tpe . > filter (?sub != ?tpe) > } > } > ------------------------------------------------------------------------------------------------ > > It would be great if that could be separated into: > > ------------------------------------------------------------------------------------------------ > public class MyFunc extends FunctionBase1 { > public NodeValue exec(NodeValue v) { > return NodeValue.fromSparql("filter not exists {" > + " ?sub rdfs:subClassOf ?tpe ." > + " filter (?sub != ?tpe)" > + "}") ; > } > } > // and then later > FunctionRegistry.get().put("http://example.org/function#myFunc", > MyFunc.class) ; > ------------------------------------------------------------------------------------------------ > > and then: > > ------------------------------------------------------------------------------------------------ > prefix fun:<http://example.org/function#> > select * where { > ?s a ?tpe . > filter(fun:myFunc(?tpe)) > } > ------------------------------------------------------------------------------------------------ > > Basically I'm looking for a way to call a SPARQL query from within a SPARQL > query. Is that possible? > > -- Lorenz Bühmann AKSW group, University of Leipzig Group: http://aksw.org - semantic web research center