In RDF-Turtle, what is the difference between using a @base
prefix and empty prefix (with just :
)?
1 Answers
@base
is not a prefix declaration, but a... well, a base declaration. It declares a document's base location, against which all relative IRIs are resolved. @prefix :
is a prefix declaration (in this case for the default or empty prefix), against which all prefixed names with an empty prefix are resolved.
Even though they are both ways to write down an IRI, a relative IRI is not the same thing as a prefixed name. They follow different syntactical rules.
For example:
@base <http://example.org/base/>
@prefix : <http://example.org/prefix/>
<name> rdf:type rdf:Property .
:phone rdf:type rdf:Property .
In this example name
is a relative IRI. The base declaration will be used to resolve it to the absolute IRI http://example.org/base/name
.
:phone
is not a relative IRI, but a prefixed name (with an empty prefix). The (empty) prefix declaration will be used to resolve it to the absolute IRI http://example.org/prefix/phone
.
Easy way to tell the difference between an IRI and a prefixed name in Turtle: the former has <>
brackets around it.

- 9,069
- 2
- 22
- 37

- 21,642
- 4
- 51
- 73
-
1From your answer I see, that there is a difference in syntax, but I keep asking myself, which one should I use, and why do both of them exist? – hoijui Nov 04 '19 at 09:31
-
2@hoijui one reason is that base URIs give a mechanism to use relative paths in the data, and then use an _external_ base URI (instead of whatever is declared in the file) to resolve them. This can be useful for things like hosting the same data in multiple locations. – Jeen Broekstra Apr 21 '21 at 00:32
-
1so `@base` is preferable, as it allows for more flexibility, and has no down-side to it? – hoijui Jun 11 '21 at 04:16