如何在同一个SPARQL查询中交替使用两个VALUES模式

时间:2017-03-16 13:34:50

标签: sparql

如何修改下面的代码,以便机器根据?描述值选择合适的VALUES模式?这样的修改是否可能?

PREFIX e: <http://learningsparql.com/ns/expenses#> 

SELECT ?description ?date ?amount
WHERE
{
  ?meal e:description ?description ;
        e:date ?date ;
        e:amount ?amount .

   VALUES ( ?description ?date) {
             ("lunch" "2011-10-15" ) 
             ("dinner" "2011-10-16" )
      } 

   VALUES ( ?description ?amount) {
         ("breakfast" "2") 
         ("brunch" "5" )
  }       

}

提前谢谢你......

1 个答案:

答案 0 :(得分:1)

也许你可以这样做:

PREFIX e: <http://learningsparql.com/ns/expenses#> 

SELECT ?description ?date ?amount
WHERE
{
  ?meal e:description ?description ;
        e:date ?date ;
        e:amount ?amount .

   VALUES ( ?description ?date         ?amount ) {
          ( "lunch"      "2011-10-15"  UNDEF ) 
          ( "dinner"     "2011-10-16"  UNDEF )
          ( "breakfast"  UNDEF         "2" ) 
          ( "brunch"     UNDEF         "5" )
   }       
}

UNDEF表示该变量未绑定。