SPARQL 中井号 (#) 的含义是什么?
What's the meaning of hash sign (#) in SPARQL?
在 SPARQL 中,我经常看到在前缀定义末尾使用#,如下所示:
@prefix dt: <http://example.org/datatype#>
目的是什么?我在 SPARQL 文档中找不到这个。
您的示例似乎在 Turtle 中,因为在 SPARQL 中语法为:
PREFIX dt: <http://example.org/datatype#>
但思路相同:不必在查询中使用完整的 IRI,您可以使用 prefixed names:
在您的示例中,前缀标签 是dt
。它映射到 IRI http://example.org/datatype#
.
在您的查询中,它可能被用作 dt:foobar
,其中 foobar
称为 本地部分 .
来自前缀标签和本地部分的映射 IRI 连接起来形成“实际”IRI :
http://example.org/datatype#
+ foobar
=
http://example.org/datatype#foobar
(除了使用 dt:foobar
,您还可以使用 <http://example.org/datatype#foobar>
。)
所以 #
恰好是 IRI 设计的一部分。这是在语义 Web 中构建词汇 IRI 的一种流行方式。另一种流行的方式是使用 /
。参见 HashVsSlash。
在 SPARQL 中,我经常看到在前缀定义末尾使用#,如下所示:
@prefix dt: <http://example.org/datatype#>
目的是什么?我在 SPARQL 文档中找不到这个。
您的示例似乎在 Turtle 中,因为在 SPARQL 中语法为:
PREFIX dt: <http://example.org/datatype#>
但思路相同:不必在查询中使用完整的 IRI,您可以使用 prefixed names:
在您的示例中,前缀标签 是
dt
。它映射到 IRIhttp://example.org/datatype#
.在您的查询中,它可能被用作
dt:foobar
,其中foobar
称为 本地部分 .来自前缀标签和本地部分的映射 IRI 连接起来形成“实际”IRI :
http://example.org/datatype#
+foobar
=
http://example.org/datatype#foobar
(除了使用
dt:foobar
,您还可以使用<http://example.org/datatype#foobar>
。)
所以 #
恰好是 IRI 设计的一部分。这是在语义 Web 中构建词汇 IRI 的一种流行方式。另一种流行的方式是使用 /
。参见 HashVsSlash。