Hi Martynas,

the built-in SPARQL expression modules are defined in SPL, e.g.


sp:ge   a                spin:Function ;
        rdfs:comment     "Returns true if ?arg1 >= ?arg2." ;
        rdfs:label       "ge"^^xsd:string ;
        rdfs:subClassOf  spl:BooleanFunctions ;
        spin:constraint  [ a              spl:Argument ;
                           rdfs:comment   "the first operand" ;
                           spl:predicate  sp:arg1 ;
                           spl:valueType  rdfs:Literal
                         ] ;
        spin:constraint  [ a              spl:Argument ;
                           rdfs:comment   "the second operand" ;
                           spl:predicate  sp:arg2 ;
                           spl:valueType  rdfs:Literal
                         ] ;
        spin:returnType  xsd:boolean ;
        spin:symbol      ">="^^xsd:string .

this means that you could write a SPARQL query that walks through the declared spin:constraints to find the number of required arguments for each function/expression. In fact, spl:Argument is a template that defines a constraint that you could evaluate with the SPIN constraint checker itself.

HTH
Holger


On 6/27/2014 7:49, [email protected] wrote:
Hey,

I have a situation where SPIN expression arguments come in directly from user input (faceted search). For example, sp:arg2 as numeric literal for sp:ge or as plain literal for sp:regex.

The problem is, that if the user submits the SPIN RDF with empty input values, sp:arg2 property is missing on expression, and building a query I either get a com.hp.hpl.jena.query.QueryParseException or this:

java.lang.ArrayIndexOutOfBoundsException: 2
org.topbraid.spin.model.impl.FunctionCallImpl.getArgumentProperties(FunctionCallImpl.java:65)
org.topbraid.spin.model.impl.FunctionCallImpl.getArguments(FunctionCallImpl.java:49)
org.topbraid.spin.model.impl.FunctionCallImpl.print(FunctionCallImpl.java:172)
org.topbraid.spin.util.SPINExpressions.printExpressionString(SPINExpressions.java:204)
org.topbraid.spin.model.impl.AbstractSPINResourceImpl.printNestedExpressionString(AbstractSPINResourceImpl.java:146)
org.topbraid.spin.model.impl.FilterImpl.print(FilterImpl.java:46)
org.topbraid.spin.model.impl.ElementListImpl.print(ElementListImpl.java:139)
org.topbraid.spin.model.impl.AbstractSPINResourceImpl.printNestedElementList(AbstractSPINResourceImpl.java:132)
org.topbraid.spin.model.impl.QueryImpl.printWhere(QueryImpl.java:221)
org.topbraid.spin.model.impl.SelectImpl.printSPINRDF(SelectImpl.java:99)
org.topbraid.spin.model.impl.QueryImpl.print(QueryImpl.java:117)
org.topbraid.spin.model.impl.SubQueryImpl.print(SubQueryImpl.java:44)
org.topbraid.spin.model.impl.ElementListImpl.print(ElementListImpl.java:139)
org.topbraid.spin.model.impl.UnionImpl.print(UnionImpl.java:33)
org.topbraid.spin.model.impl.ElementListImpl.print(ElementListImpl.java:139)
org.topbraid.spin.model.impl.AbstractSPINResourceImpl.printNestedElementList(AbstractSPINResourceImpl.java:132)
org.topbraid.spin.model.impl.QueryImpl.printWhere(QueryImpl.java:221)
org.topbraid.spin.model.impl.ConstructImpl.printSPINRDF(ConstructImpl.java:55)
org.topbraid.spin.model.impl.QueryImpl.print(QueryImpl.java:117)
org.topbraid.spin.arq.ARQFactory.createCommandString(ARQFactory.java:125)
org.topbraid.spin.arq.ARQFactory.createQuery(ARQFactory.java:219)


What would be the shortest way to check if expression has all arguments it needs? If it doesn't, I can ignore it. Does it always have to have sp:arg2?

Thanks.

Martynas
graphityhq.com
--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
---
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 [email protected] <mailto:[email protected]>.
For more options, visit https://groups.google.com/d/optout.

--
-- You received this message because you are subscribed to the Google
Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary 
Network (EVN), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL 
Web Pages and SPIN.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/topbraid-users?hl=en
--- 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to