sim*_*412 2 owl sparql protege
我有一个问题:在 sparql 中,@prefix 做了什么:
@前缀:http : //example.org/animals/
为什么要这样写?
Jeen Broekstra 的回答是正确的; @prefix <...>不是合法的 SPARQL 语法,只会为您产生语法错误。但是,在 RDF 的 Turtle 和 N3 序列化中也有类似的结构。在这些语法中,代码
@prefix animals: <http://example.org/animals/>.
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>.
animals:Moose rdfs:subClasof animals:Animal
Run Code Online (Sandbox Code Playgroud)
是具有单个三元组的图:
<http://example.org/animals/Moose> <http://www.w3.org/2000/01/rdf-schema#subClassOf> <http://example.org/animals/Animal>
Run Code Online (Sandbox Code Playgroud)
这些@prefix行定义了前缀,以便在图形的序列化中更容易地引用 IRI。SPARQL 也有前缀声明,但语法有点不同。在 SPARQL 查询中,@行首没有.,行尾也没有。因此,继续上面的示例,您可以animal:Animal使用以下查询查询子类的所有内容:
prefix an: <http://example.org/animals/>
prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#>
select ?subclass where {
?subclass rdfs:subClassOf an:Animal
}
Run Code Online (Sandbox Code Playgroud)
请注意,在第一次序列化中,我们使用了animals:但在 SPARQL 查询中,我们使用an:了相同的前缀。特定的前缀无关紧要,只要它扩展到的实际(部分)URI 相同即可。严格来说,前缀是为了人的方便;它们并不是绝对必要的。
| 归档时间: |
|
| 查看次数: |
2813 次 |
| 最近记录: |