How to register SHACL functions and make it available in SPARQL queries?

22 views
Skip to first unread message

Alex To

unread,
Oct 7, 2017, 2:17:21 AM10/7/17
to TopBraid Suite Users
Hi, I have been struggle with how to make custom SHACL functions and use it in my SPARQL queries.

I have an application based on Jena. I can write custom functions that extend FunctionBaseXXX and register the functions and then execute the functions successfully as described here


I am new to SHACL but if I understand it correctly, I can also write function in SHACL and TopBraid API can make it available in my SPARQL queries as well? 

What steps do I have to do to achieve this? At a high level, I think I have to do the following

1. Define SHACL functions as triples
2. Import these triples into my Jena dataset ????
3. Somehow register these SHACL functions with FunctionRegistry ?? how do I do that with TopBraid SHACL API ??


The thing that I can't figure out is how to make Jena aware that I have such SHACL functions and where should I store those functions?

Thank you

Best Regards

Holger Knublauch

unread,
Oct 7, 2017, 7:28:10 PM10/7/17
to topbrai...@googlegroups.com
Hi Alex,

to install SHACL functions, load the graph containing their definitions (including the required sub-graphs via owl:imports) and call
   
        // Make sure all sh:Functions are registered
        SHACLFunctions.registerFunctions(shapesModel);

See ValidationUtil.validateModel, which does this. Once called, the functions are added to Jena's functions registry and can be called like any other SPARQL function, from any SPARQL query.

Regards
Holger
--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Alex To

unread,
Oct 12, 2017, 8:17:52 AM10/12/17
to TopBraid Suite Users
Yeah, I figured it out right after I posted this. 

Thank you very much
Reply all
Reply to author
Forward
0 new messages