On Mon, 18 Oct 2021, at 21:54, Fons Adriaensen wrote:
Which raises the question why those @prefix lines are
required at all. [...]
So all that these lines seem to provide is some illusion
of conformity which isn't enforced or checked at all.
I used to find this conceptually tricky as well. I think it's true that there is an
illusion of conformance there. The @prefix lines have an official look to them that
doesn't reflect the reality, which is simpler than it appears.
RDF itself is a structure of triples, in which each element (subject, predicate, object)
can be a URI (a string with some limitations as to character content) or, in certain
positions, other types such as literal character data. RDF doesn't have prefixes
itself, they're a sort of macro expansion used in the Turtle format, which is intended
to be written and read at least partially by humans.
On loading the Turtle document
@prefix lv2: <http://lv2plug.in/ns/lv2core#> .
@prefix my: <http://mydomain/plugins/> .
my:plugin a lv2:Plugin .
what the RDF store actually receives is a single triple of three URIs, which in the more
basic ntriples format would look like
<http://mydomain/plugins/plugin>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://lv2plug.in/ns/lv2core#Plugin> .
The two prefixed names are expanded, as well as the standard shorthand "a". But
you didn't *have* to use the prefixes, you could have written exactly the line above
(which is valid Turtle as well as ntriples). It's just that it's harder to write
the document correctly that way. All that matters is that the second and third URIs
(predicate and object) expand to exactly the strings shown, and that the first URI (the
subject) is used consistently as the subject for all properties of your plugin.
So the above document is equivalent to any other Turtle document that expands to the same
set of RDF triples. For example, I could have chosen to write
@prefix plu: <http://lv2plug.in/ns/lv2core#plu> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://mydomain/plugins/plugin> rdf:type plu:gin .
Run this through a Turtle-to-ntriples converter (e.g. rapper -i turtle) and you'll get
the same output as before:
<http://mydomain/plugins/plugin>
<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>
<http://lv2plug.in/ns/lv2core#plugin> .
And, of course, URIs are just strings - the fact that they are typically written with http
at the start etc is just a namespacing convention. The lv2 standard could have used
<e274923af6ffac82ad3f5beebb015380> instead of
<http://lv2plug.in/ns/lv2core#plugin> and it would still work.
Chris