Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a syntax to define cyclic reference between anonymous nodes in Turtle RDF?

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?

like image 651
Thibaut Guirimand Avatar asked Feb 23 '15 14:02

Thibaut Guirimand


1 Answers

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.

like image 129
Alex Avatar answered Nov 21 '22 00:11

Alex