Warning:
This wiki has been archived and is now read-only.
Graphs-In-Turtle
Contents
Graphs in Turtle Strawman
Assumptions:
Alignment with SPARQL is more important then alignment with N3.
The community does not have a lot of investment in TriG syntax.
The community has some investment in N-Quads.
Advantages of N-Quads:
No state outside current line.
Questions?
Is it possible for something N-Quad like to be a Subset of Graphs in Turtle?
Strawman
SPARQL uses the GRAPH keyword when talking about graphs, SPARQL keywords tend to match @* keywords in Turtle. @graph seems to follow.
While context coming last in N-Quads makes some sense, providing notation of the graph at the end of a statement doesn't work very well with multi line statements.
# N-Graphs
@graph <http://example.org/alice/foaf.rdf> . <http://example.org/alice/foaf.rdf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
@graph <http://example.org/alice/foaf.rdf> . <http://example.org/alice/foaf.rdf#me> <http://xmlns.com/foaf/0.1/name> "Alice" .
@graph <http://example.org/bob/foaf.rdf> . <http://example.org/bob/foaf.rdf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
@graph <http://example.org/bob/foaf.rdf> . <http://example.org/bob/foaf.rdf#me> <http://xmlns.com/foaf/0.1/name> "Bob" .
# Graphs in Turtle
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix void: <http://rdfs.org/ns/void#> .
<> a void:Dataset . # no graph statement yet, must be default graph
@base <http://example.org/alice/foaf.rdf> . #setup a new base
@graph <> . #base matches graph name
<#me> a foaf:Person ;
foaf:name "Alice";
.
@base <http://example.org/bob/foaf.rdf> .
@graph <> .
<#me> a foaf:Person ;
foaf:name "Bob";
.
@graph . #go back to the default graph
<http://example.org/alice/foaf.rdf> a foaf:Document .
<http://example.org/bob/foaf.rdf> a foaf:Document .
(AndyS) GRAPH in SPARQL takes a URI and a {} block of triples, in both update and query. GRAPH blocks do not nest in data. SPARQL does not insist on trailing dots before a } or before GRAPH.
PREFIX : <http://example/>
INSERT DATA {
<s> <p> 123 .
GRAPH :graph1 {
<s2> <p> "foo"@en .
}
}
Trig Strawman
Denote graphs with {}s:
# N-Graphs
<http://example.org/alice/foaf.rdf> {
<http://example.org/alice/foaf.rdf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
<http://example.org/alice/foaf.rdf#me> <http://xmlns.com/foaf/0.1/name> "Alice" .
}
<http://example.org/bob/foaf.rdf> {
<http://example.org/bob/foaf.rdf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
<http://example.org/bob/foaf.rdf#me> <http://xmlns.com/foaf/0.1/name> "Bob" .
}
# Graphs in Turtle
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix void: <http://rdfs.org/ns/void#> .
<> a void:Dataset . # no graph statement yet, must be default graph
@base <http://example.org/alice/foaf.rdf> . #setup a new base
<> { #base matches graph name
<#me> a foaf:Person ;
foaf:name "Alice";
.
}
@base <http://example.org/bob/foaf.rdf> .
<> {
<#me> a foaf:Person ;
foaf:name "Bob";
.
}
# Not inside {}s so in the default graph:
<http://example.org/alice/foaf.rdf> a foaf:Document .
<http://example.org/bob/foaf.rdf> a foaf:Document .