3

It it possible to have a Turtle file with two empty prefixes?

Imagine that we have a .ttl file with this prefixes declaration:

@prefix : <http://www.example.com/example#> .
@prefix ex2: <http://www.ex2.com/ex2#> .
@prefix ex3: <http://www.ex3.com/ex3#> .
@prefix : <http://www.empty.com/empty#> .
...

Where do all the empty prefixes will be resolved: http://www.example.com/example# or http://www.empty.com/empty#?

unor
  • 92,415
  • 26
  • 211
  • 360
tremendows
  • 4,262
  • 3
  • 34
  • 51

2 Answers2

3

The specification defines it as a mapping Map[prefix -> IRI] so, no, you cannot have two for the same prefix (including the empty prefix).

Ian Mercer
  • 38,490
  • 8
  • 97
  • 133
2

You can have multiple definitions in a single file but only one can be in scope at a time.

For example:

@prefix : <http://example.com/one#> .
:s :p :o .
@prefix : <http://example.com/two#> .
:s :p :o .

Would result in two triples because the file is parsed sequentially so the prefix mapping at the point at which a triple definition is encountered determines how it is resolved.

While this is perfectly valid input you will struggle to find a library that allows you to produce this as output. And realistically it is probably best to avoid redefining prefixes during the course of a file because it reduces the human readability of the file and reduces the ability to cut and paste content within the file.

RobV
  • 28,022
  • 11
  • 77
  • 119