我有一个SPARQL查询,类似于这样:
SELECT ?informationPath ?businessEntitylabel ?path ?sourced ?mastered ?delivered
WHERE {
?businessEntity dd:hasPropertyPath ?informationPath .
?businessEntity rdfs:label ?businessEntitylabel .
?informationPath dd:hasPath ?path .
OPTIONAL {
?informationPath a dd:SourcedData .
BIND("Yes" as ?sourced)
}
OPTIONAL {
?informationPath a dd:MasteredData .
BIND("Yes" as ?mastered)
}
OPTIONAL {
?informationPath a dd:DeliveredData .
BIND("Yes" as ?delivered)
}
} ORDER BY ?businessEntitylabel ?path
现在我想只有一列,而不是?sourced ?mastered ?delivered和名称为?traceability。该列将显示一个?informationPath是否为Mastered数据或Sourced数据或Delivered数据,并相应地我想要BIND(“Sourced data”作为?traceability)或(“Mastered data”作为?traceability)或(“Delivered data”作为?traceability)
我是SPARQL的新手,我想知道SPARQL中是否有任何可以用作的“if”语句-
if(?informationPath a dd:SourcedData)
BIND("SourcedData" as ?traceability)
任何帮助将不胜感激。
if
运算符,并且在规范的17.4.1.2 IF中清楚地描述了它。在您的情况下,您可以执行类似于bind( if( …, "Sourced, if( …, "Delivered", if ( …, "Mastered", "Unknown" ) ) ) as ?traceability )
的操作。 - Joshua Taylor