HI Jamey,

Does Virtuoso provide some supported way to write one's own custom SPARQL extension functions (http://www.w3.org/TR/rdf-sparql-query/#extensionFunctions )?


Yes, there are actually two options:

Firstly, you can create a stored procedure in Virtuoso PL and call it using the sql: prefix:

   SELECT * where { ?s ?p `sql:testfunc(?o)` }
        
See: http://docs.openlinksw.com/virtuoso/rdfsparql.html#rdfsqlfromsparql

Secondly you can make a build in function which is basically a C function that can be called from both SQL and SPARQL as in the following examples, using the bif: prefix:

In this example we use the CONTAINS function to do a freetext search on all ?o that contain words starting with Timo.

SELECT * FROM <http://www.w3.org/people#> WHERE { ?s ?p ?o . ?o bif:contains '"Timo*"'}

See: 
http://docs.openlinksw.com/virtuoso/sparqlextensions.html#rdfsparqlrulefulltext

You can basically use relevant functions from the Virtuoso Functions Guide inside your SPARQL query.

See: http://docs.openlinksw.com/virtuoso/functions.html



Best regards,

Patrick

Reply via email to