我最近在许多 SPARQL 查询中使用了 VALUES,只是意识到在其中一个查询中我没有得到我期望的结果。
这是一个简单的案例:
@prefix ns: <http://some/ns> .
<http://some/uri> a ns:Document ;
ns:A5000 "00003381" ;
ns:A5080 "sredniowiecze" .
我正在使用 VALUES 将 nsA5080 文字“翻译”为 URI。简单查询:
PREFIX ns: <http://some/ns>
SELECT ?document ?u ?p ?lp
WHERE
{
?document ns:A5080 ?p .
VALUES (?p ?u) {
( "sredniowiecze" ns:MiddleAges )
( "other" ns:Other )
}
}
按预期工作:
Document U P LP
<http://some/uri> <http://some/nsMiddleAges> "sredniowiecze"
但如果我将其更改为:
SELECT ?document ?u ?p ?lp
WHERE
{
?document ns:A5080 ?p .
BIND ( LCASE(?p) AS ?lp )
VALUES (?lp ?u) {
( "sredniowiecze" ns:MiddleAges )
( "other" ns:Other )
}
}
我正进入(状态:
Document U P Lp
<http://some/uri> <http://some/nsMiddleAges> "sredniowiecze" "sredniowiecze"
<http://some/uri> <http://some/nsOther> "sredniowiecze" "sredniowiecze"
这对我没有任何意义。额外的元组从何而来?在真正的查询中,我有 ca。VALUES 中有 30 多个元组,它们都落在结果中。还有什么更有趣的查询,看起来几乎像那个查询 - 在其他任何地方都可以正常工作。
想法?