SPARQL functions in CONSTRUCT/WHERE

后端 未结 2 2092
别跟我提以往
别跟我提以往 2020-12-02 02:23

I mostly use SPARQL SELECT while working on a query for debugging purposes but in the end I want to use the final result it in a CONSTRUCT way; as I want to work with a grap

2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-02 02:33

    Yes this is possible

    You can't use expressions directly in a CONSTRUCT template but you can assign the variable in the WHERE clause either via a SELECT expression in a sub-query or using BIND.

    In your case as GROUP_CONCAT is an aggregate it can only be a SELECT expression so you just need to put your entire SELECT as a sub-query e.g.

    PREFIX dc:     
    
    CONSTRUCT
    {
        ?fancytitle
    }
    WHERE
    {
      SELECT (group_concat(?title ; separator = " ") AS ?fancytitle) WHERE { 
        GRAPH ?graph {
            dc:relation+ ?relation .
          ?relation dc:title ?title .
        }
      }
    }
    

    The above works fine on your endpoint

提交回复
热议问题