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:
- Cycles in a graph involving more than one anonymous node.
- Multiple triples having the same anonymous node as the object.
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.
'#1=(a b c . #1#)
, and that notation works for any repeated stuff, e.g., a list of length two with the element repeated can be'(#1=(a b c) #1#)
. I really wish Turtle had something like this. – Sententious