这很难回答,因为您没有显示您的数据。但是,如果我们假设您有一些这样的数据:
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://example.org/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:curfew="http://example.org/curfew/">
<rdf:Description rdf:about="http://example.org/c">
<curfew:NumberInLine rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>45.0</curfew:NumberInLine>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/a">
<curfew:NumberInLine rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>50.0</curfew:NumberInLine>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/d">
<curfew:NumberInLine rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>47.0</curfew:NumberInLine>
</rdf:Description>
<rdf:Description rdf:about="http://example.org/b">
<curfew:NumberInLine rdf:datatype="http://www.w3.org/2001/XMLSchema#float"
>60.0</curfew:NumberInLine>
</rdf:Description>
</rdf:RDF>
然后你可以用同样的方式过滤(使用contains),查询如下:
prefix curfew: <http://example.org/curfew/>
prefix : <http://example.org/>
select ?c ?number where {
?c curfew:NumberInLine ?number .
filter( contains( str(?number), "5" ))
}
---------------------------------------------------------
| c | number |
=========================================================
| :c | "45.0"^^<http://www.w3.org/2001/XMLSchema#float> |
| :a | "50.0"^^<http://www.w3.org/2001/XMLSchema#float> |
---------------------------------------------------------
不过,如果您使用数字类型,则根据数字属性进行过滤会更常见。例如,
prefix curfew: <http://example.org/curfew/>
prefix : <http://example.org/>
select ?c ?number where {
?c curfew:NumberInLine ?number .
filter( ?number < 50.0 )
}
---------------------------------------------------------
| c | number |
=========================================================
| :d | "47.0"^^<http://www.w3.org/2001/XMLSchema#float> |
| :c | "45.0"^^<http://www.w3.org/2001/XMLSchema#float> |
---------------------------------------------------------