I'm looking for a turtle syntax for calling the anonymous node who call an other anonymous node.
For example, I want to reproduce this code :
:Instance0 a Class0;
:property0 :Instance1.
:Instance1 a Class1;
:property1 :Instance2.
:Instance2 a Class2;
:property2 :Instance1.
With something like :
:Instance0 a Class0;
:property0 [
a Class1;
:property1 [
a Class2;
:property2 [
## The syntax to call the parent, the instance of :Class1
];
];
].
Is there any turtle syntax for this purpose?
RDF's data model is graph-based, not hierarchical, so there is no notion of parent/child relationships between resources, and hence no built-in syntax to refer to 'parent' nodes when nesting anonymous resource descriptions with the []
construct (which is really just syntactic sugar for grouping together a bunch of triples sharing the same anonymous subject).
That being said, Turtle's syntax is capable of serializing every conforming RDF graph. To achieve the graph structure that you describe, you must use the _:
syntax rather than the more compact []
syntax for defining anonymous nodes.
Situations where you must use the _:
syntax to manually assign blank node labels instead of using the []
convenience syntax include:
The _:
syntax allows you to manually assign a node identifier, which will allow you to refer to the blank node from the subject or object position of any arbitrary triple. The node identifier that you assign has no meaning outside the context of the Turtle document in which it appears, and so need not be globally unique. Nodes identified this way are still anonymous, because they cannot be globally referenced. However, every occurrence of the same blank node label inside the same document refers to the same resource, so the writer of the document is responsible for allocating blank node labels and tracking their usage within the same document.
Your document, then, would look something like:
:Instance0 a Class0;
:property0 _:instance1.
_:instance1 a Class1;
:property1 [
a Class2;
:property2 _:instance1;
].
See 2.6 RDF Blank Nodes in RDF 1.1 Turtle, Terse RDF Triple Language for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With