如何忽略 SPARQL 中的 VALUES?
How to ignore VALUES in SPARQL?
我的部分查询如下所示:
GRAPH g1: {VALUES (?ut) {$U1}
?IC_uri skos:related ?ut .
}
通常,根据用户输入,$U1
获取 URI 列表。我想发送 $U1
的值用于测试目的,以便忽略值的声明并考虑所有可能的值。事实上,它应该产生与以下相同的结果:
GRAPH g1: {
# VALUES (?ut) {$U1}
?IC_uri skos:related ?ut .
}
我记得有一种方法可以做到这一点,但我在 SPARQL 规范中找不到它。
我会提出三个选项:
FILTER (?ut IN ($ut))
,传递 $ut
而不是 URI 列表;
BIND ($ut as ?ut)
,传递 $ut
而不是单个 URI;
VALUES (?ut) {(UNDEF)}
,传递 (UNDEF)
而不是 space 分隔的(括号括起来的)URI 列表。
不能认为此类 SPARQL 注入是安全的。
10.2.2 VALUES Examples中首次提到的UNDEF
关键字:
If a variable has no value for a particular solution in the VALUES
clause, the keyword UNDEF
is used instead of an RDF term.
我的部分查询如下所示:
GRAPH g1: {VALUES (?ut) {$U1}
?IC_uri skos:related ?ut .
}
通常,根据用户输入,$U1
获取 URI 列表。我想发送 $U1
的值用于测试目的,以便忽略值的声明并考虑所有可能的值。事实上,它应该产生与以下相同的结果:
GRAPH g1: {
# VALUES (?ut) {$U1}
?IC_uri skos:related ?ut .
}
我记得有一种方法可以做到这一点,但我在 SPARQL 规范中找不到它。
我会提出三个选项:
FILTER (?ut IN ($ut))
,传递$ut
而不是 URI 列表;BIND ($ut as ?ut)
,传递$ut
而不是单个 URI;VALUES (?ut) {(UNDEF)}
,传递(UNDEF)
而不是 space 分隔的(括号括起来的)URI 列表。
不能认为此类 SPARQL 注入是安全的。
10.2.2 VALUES Examples中首次提到的UNDEF
关键字:
If a variable has no value for a particular solution in the
VALUES
clause, the keywordUNDEF
is used instead of an RDF term.