3

I'm currently developing a project in which I use AllegroGraph as graph database. AllegroGraph provides full support for SPARQL 1.1 Query and Update. I'm trying to write a SPARQL query in which I need some math functions (such as square root and so on). The problem is that every namespace I found isn't working. For example, I tried to use the xpath namespace for the math functions (https://www.w3.org/2005/xpath-functions/math) in this way:

PREFIX func:<http://www.w3.org/2005/xpath-functions/math#>

SELECT ?res 
WHERE {
    BIND(func:sqrt(4) as ?res) .
}

but it doesn't work since I get the following error:

QUERY FAILED: URI function <http://www.w3.org/2005/xpath-functions/math#sqrt> is not defined

Can you help me to find a workaround please?

Thanks in advance!

Stanislav Kralin
  • 11,070
  • 4
  • 35
  • 58
  • 1
    I'm wondering why you think that there are such functions in the SPARQL standard? All standard functions are listed in the [W3C specs](https://www.w3.org/TR/sparql11-query/#SparqlOps), anything else are custom functions and depend on the triple store implementation. – UninformedUser Sep 14 '17 at 14:17
  • 1
    Allegrograph custom function can be found in the [documentation](https://franz.com/agraph/support/documentation/current/sparql-reference.html#header2-54), the XPath namespace would be `http://www.w3.org/2005/xpath-functions#`. But this doesn't mean that all or even any XPath function is already implemented. Again, the documentation is your friend and shows [how to add custom functions](https://franz.com/agraph/support/documentation/current/sparql-reference.html#header2-66) – UninformedUser Sep 14 '17 at 14:20

0 Answers0