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:

  1. 在您的示例中,前缀标签dt。它映射到 IRI http://example.org/datatype#.

  2. 在您的查询中,它可能被用作 dt:foobar,其中 foobar 称为 本地部分 .

  3. 来自前缀标签本地部分的映射 IRI 连接起来形成“实际”IRI :

    http://example.org/datatype# + foobar =
    http://example.org/datatype#foobar

  4. (除了使用 dt:foobar,您还可以使用 <http://example.org/datatype#foobar>。)

所以 # 恰好是 IRI 设计的一部分。这是在语义 Web 中构建词汇 IRI 的一种流行方式。另一种流行的方式是使用 /。参见 HashVsSlash