I have a Fuseki endpoint running on some kind of server. I would like to pass custom functions using the Jena com.hp.hpl.jena.sparql.function library. Sorry, I get an error:
URI <java:path.to.functions.halfString> has no registered function factory
I have definitely added a class (the jar containing the file) to the class path, and I can access this class from other applications that use this class on this server.
The example I'm trying to apply now is some function that takes an object of all triples in a graph and returns the first half of each object.
As a reference, I added a function below:
public class halfString extends FunctionBase1 { public halfString() { super() ; } public NodeValue exec(NodeValue nv1) { if (!nv1.isString()) { return nv1; } String hey = nv1.toString(); int mid = hey.length() / 2; String nay = hey.substring(0, mid); return NodeValue.makeString(nay); } }
Here is the SPARQL query that I used:
PREFIX f: <path.to.functions.> SELECT ?half ?s ?o ?g WHERE { ?s ?p ?o BIND (f:halfString(str(?s)) as ?half) }
Running Fuseki (using the default configuration provided with fuseki):
cd FUSEKI_HOME ./fuseki-server --mem /ds
source share