|
Can we write our own custom function in SPARQL? If yes, please give one example. |
|
There is no standard way to write custom functions in SPARQL. SPARQL does support the invocation of custom functions (named by URI), however, and many SPARQL implementations, however, provide a way to extend the set of functions that they include. My company's semantic platform, Anzo, for example, lets you write new SPARQL functions in Java, JavaScript, or by using Excel-like formulas. |
|
SPARQL Inferencing Notation, or SPIN (not a standard, but a W3C member submission) lets you define your own SPARQL functions in SPARQL. http://www.topquadrant.com/docs/tbc/AppDevQuickstartGuide/howtospinfunctions.html describes how to do this with TopQuadrant's TopBraid Composer. (Disclaimer: I work for TopQuadrant.) |
|
As lee said, there's no standard way to do this, but many tools have their own way to support creation of custom functions. Sesame, for example, allows you to add custom functions in Java - here's an article that explains how (ObDisclosure: I am on the Sesame development team). |
|
As others have said SPARQL supports the notion of identifying custom functions with URIs - see Extensible Value Testing in the SPARQL specification Again echoing others answers how you do this differs from implementation to implementation:
Disclaimer - I am a developer on both the above projects |

