How to recursively expand blank nodes in SPARQL construct query?

前端 未结 3 1686
南方客
南方客 2021-02-20 00:10

There is probably an easy to answer to this, but I can\'t even figure out how to formulate the Google query to find it.

I\'m writing SPARQL construct queries against a d

3条回答
  •  滥情空心
    2021-02-20 00:33

    Recursion isn't possible. The closest I can think of is SPARQL 1.1 property paths (note: that version is out of date) but bnode tests aren't available (afaik).

    You could just remove the statements with trailing bnodes:

    CONSTRUCT {?x ?y ?z .} WHERE 
    {
      ?x ?y ?z .
      FILTER (!isBlank(?z))
    }
    

    or try your luck fetching the next bit:

    CONSTRUCT {?x ?y ?z . ?z ?w ?v } WHERE 
    {
      ?x ?y ?z .
      OPTIONAL {
        ?z ?w ?v
        FILTER (isBlank(?z) && !isBlank(?v))
      }
    }
    

    (that last query is pretty punishing, btw)

    You may be better off with DESCRIBE, which will often skip bnodes.

提交回复
热议问题