|
Hello Tim; The SPARQL standard does not support
arithmetic operators beyond =, -, *, / (numeric division) and
unary + and -. For mod/div, the best bet is to use SPINx and use
_javascript_ definitions. See Help > SPIN > Using _javascript_
to define SPIN/SPARQL Functions. The attached file defines two functions basicMath:mod() and basicMath:div(). Place these files anywhere in your workspace and refresh SPARQLMotion functions, and you can call the functions with LET or FILTER clauses: FILTER ((basicMath:mod(?x, ?y) = 0)) LET (?value := basicMath:div(?x, ?y)) You don't need to import the file to use them - the .sms files will be scanned at Composer/Live startup and globally available across all files in the workspace. -- Scott On 11/30/10 8:31 AM, Tim Darr wrote: --Are the mod and div operators available in TBC (for SPARQL queries)? If so, what is the namespace and syntax?-Thanks- You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include TopBraid Composer, TopBraid Live, TopBraid Ensemble, SPARQLMotion 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 |
# Saved by TopBraid on Tue Nov 30 09:15:26 CST 2010 # baseURI: http://support.tq.com/basicMath # imports: http://topbraid.org/sparqlmotionfunctions # imports: http://topbraid.org/sparqlmotionlib # imports: http://spinrdf.org/spinx @prefix basicMath: <http://support.tq.com/basicMath#> . @prefix owl: <http://www.w3.org/2002/07/owl#> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix sp: <http://spinrdf.org/sp#> . @prefix spin: <http://spinrdf.org/spin#> . @prefix spinx: <http://spinrdf.org/spinx#> . @prefix spl: <http://spinrdf.org/spl#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . <http://support.tq.com/basicMath> rdf:type owl:Ontology ; owl:imports <http://spinrdf.org/spinx> , <http://topbraid.org/sparqlmotionlib> , <http://topbraid.org/sparqlmotionfunctions> ; owl:versionInfo "Created with TopBraid Composer"^^xsd:string . basicMath:div rdf:type spin:Function ; rdfs:subClassOf spin:Functions ; spin:constraint [ rdf:type spl:Argument ; spl:predicate sp:arg1 ; spl:valueType xsd:integer ] ; spin:constraint [ rdf:type spl:Argument ; spl:predicate sp:arg2 ; spl:valueType xsd:integer ] ; spin:returnType xsd:integer ; spinx:javaScriptCode "return arg1 / arg2;"^^xsd:string . basicMath:mod rdf:type spin:Function ; rdfs:subClassOf spin:Functions ; spin:constraint [ rdf:type spl:Argument ; spl:predicate sp:arg2 ; spl:valueType xsd:integer ] ; spin:constraint [ rdf:type spl:Argument ; spl:predicate sp:arg1 ; spl:valueType xsd:integer ] ; spin:returnType xsd:integer ; spinx:javaScriptCode "return arg1 % arg2;"^^xsd:string .
