Jack; The problem may be that SPARQL's declarative nature does not
impose any ordering on its statements. One should be able to place
the statements in any order and the result will be the same. In your case, you need to make sure the ?res1 and ?res2 binding are performed before the IF statement, so you can include this in a graph statement. The SPARQL engine will execute the graphs inside-out. (If you're interested in the actual ordering of the clauses, and don't mind a bit of Lisp-like syntax, then you can take a look at the query in the "Debug query". This will at least let you know whether or not an ordering is being sent to the SPARQL engine.) So, the following ought to do what you need by specifying that the first two statements are executed before the rest. SELECT DISTINCT *
WHERE {
{ BIND
(act:commonSubclassLabel("http://developer.runkeeper.com/healthgraph#Spinning")
AS ?res1) .
BIND
(act:commonSuperclassLabel("http://developer.runkeeper.com/healthgraph#Spinning")
AS ?res2) .
} BIND ((IF(fn:string-length(?res2) > 0,
?res2, IF(fn:string-length(?res1) > 0, ?res1, "NA"))) AS
?res) .
}
-- Scott On 2/9/2015 2:16 PM, Jack Hodges wrote:
-- You received this message because you are subscribed to the Google Group "TopBraid Suite Users", the topics of which include Enterprise Vocabulary Network (EVN), Reference Data Manager (RDM), TopBraid Composer, TopBraid Live, TopBraid Insight, SPARQLMotion, SPARQL Web Pages and SPIN. To post to this group, send email to topbraid-users@googlegroups.com --- 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-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout. |
- [topbraid-users] Problem with IF in SPARQL Jack Hodges
- Re: [topbraid-users] Problem with IF in SPARQL Scott Henninger
- Re: [topbraid-users] Problem with IF in SPARQL Holger Knublauch
- Re: [topbraid-users] Problem with IF in SPARQL Jack Hodges