Daniel S.
Daniel S.

Reputation: 6640

What's the meaning of hash sign (#) in SPARQL?

In SPARQL, I often see usage of # at the end of prefix definitions, like this:

@prefix dt:   <http://example.org/datatype#>

What's the purpose? I couldn't find this in the SPARQL documentation.

Upvotes: 2

Views: 316

Answers (1)

unor
unor

Reputation: 96607

Your example seems to be in Turtle, as in SPARQL the syntax would be:

PREFIX dt: <http://example.org/datatype#>

But it’s the same idea: Instead of having to use full IRIs in your query, you can use prefixed names:

  1. In your example, the prefix label is dt. It’s mapped to the IRI http://example.org/datatype#.

  2. In your query, it might get used as dt:foobar, where foobar is called the local part.

  3. The mapped IRI from the prefix label and the local part get concatenated to form the "actual" IRI:

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

  4. (Instead of using dt:foobar, you could also use <http://example.org/datatype#foobar>.)

So the # just happens to be part of the IRI design. It’s a popular way to structure vocabulary IRIs in the Semantic Web. The other popular way is using a /. See HashVsSlash.

Upvotes: 8

Related Questions