How can different N3 sentences relate to each other and form a whole?
Namespaces enable this, by providing interoperable contexts.
Uniform Resource Identifiers
Let's get back to our Cindy and John example:
:Cindy :knows :John.
Remember: the colon means that Cindy belongs to the context of the current document.
That's not what we want.
Instead, we want to make Cindy universally identifiable.
Therefore, we provide her with a Uniform Resource Identifier or URI:
<http://example.org/people#Cindy> :knows :John.
Our Cindy is now identified by
As you can see, N3 requires angled brackets
> to keep a URI together.
This URI specifically refers to our Cindy, and not the one living 5 miles away.
However, it is not necessarily Cindy's only unique identifier. For example, URIs such as
http://paul.org/#my_neighbour could all uniquely identify the same Cindy.
Similarly, we want to identify the remaining two predicates as well. But wait!
We can avoid a lot of typing by abbreviating URIs, as illustrated below:
@prefix ppl: <http://example.org/people#>. @prefix voc: <http://example.org/vocab#>. ppl:Cindy voc:knows ppl:John.
The first line is a namespace declaration. It enables us to write
ppl:Cindy instead of
http://example.org/people#Cindy. It means the same, but it's a lot easier to type. Just look at how straightforward it was to universally identify knows and John as well.
Namespaces are a mechanism of grouping identifiers together.
They also help us reuse existing concepts.
For example, the concept “knowing someone” already exists in the Friend of a Friend (FOAF) project. We can reuse that one, instead of making up our own.
@prefix ppl: <http://example.org/people#>. @prefix foaf: <http://xmlns.com/foaf/0.1/>. ppl:Cindy foaf:knows ppl:John.
So if a stranger now reads this fragment, he might or might not have met John and Cindy, but he will understand that Cindy knows John.
We're going to write some rules.
- Uniform Resource Identifier on Wikipedia.
- The FOAF project and specification.
- The meaning of the FOAF