From 40751ac212642d87a8cf99470dc1bd583edf4e97 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 24 Jun 2026 11:27:09 +0200 Subject: [PATCH 1/3] Add SPARQL syntax sections on triple terms, reifiers, and annotations The text and structure of these new sections are mostly based on the text in the Turtle 1.2 spec, with the necessary changes to the interpretation, grammar, and examples. Closes #176 Closes #398 --- spec/index.html | 256 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 256 insertions(+) diff --git a/spec/index.html b/spec/index.html index 22b25e9..546afc5 100644 --- a/spec/index.html +++ b/spec/index.html @@ -1369,6 +1369,262 @@

rdf:type

+
+

Triple Terms

+

Within the object position of a triple pattern, + we may use a triple term or another triple pattern. +

+

Such a triple pattern or nested triple pattern + is represented as a TripleTerm with + TripleTermSubject, + Verb, and + TripleTermObject, all + preceded by <<(, and + followed by )>>. + Note that triple terms and triple patterns + may be nested. +

+

The example below shows how a triple pattern is being used in the object position of another triple pattern.

+
+              VERSION "1.2"
+              PREFIX : <http://example/>
+              PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+              SELECT ?person ?authority {
+                  ?person :familyName "Smith" .
+                  _:anno rdf:reifies <<( ?person :jobTitle "Designer" )>> .
+                  _:anno :accordingTo ?authority .
+              }
+        
+
+
+

Reifying Triples

+

Triple terms are mostly used + as the object of a triple + using the `rdf:reifies` predicate. + Such a triple is called a reifying triple. + SPARQL provides a shorthand notation for writing reifying triples + using the ReifiedTriple grammar production.

+

+

A ReifiedTriple + provides syntactic sugar to represent a reifying triple, + which defines a specific relationship between an + identifier (reifier) + and a triple term. + The identifier becomes a way to indirectly refer + to a triple term, which + may or may not be asserted within the query. +

+

Reification using triple terms is a concept distinct from the + Reification vocabulary originally + defined in RDF Semantics. + While both terms describe a representation of an RDF triple using components, + RDF 1.2 and SPARQL 1.2 uses the term to identify a triple term + using the `rdf:reifies` predicate. +

+

A reifying triple is represented using the + ReifiedTriple production + starting with <<, + followed by a ReifiedTripleSubject, + a Verb, and + a ReifiedTripleObject, + followed by an optional Reifier, + and ending with >>. + This Reifier is composed of a ~ + followed by an optional rVarOrReifierId production. + This rVarOrReifierId is composed of + a variable, IRI, or blank node. + For example, `<< :subject :predicate :object ~ :IRIREF >>`. + If no reifiers are present, + or the ~ + is not immediately followed by variable, IRI, or blank node, + a fresh RDF blank node is allocated, + as with `<< :subject :predicate :object >>`, + or `<< :subject :predicate :object ~ >>`. +

+

ReifiedTriple's may be nested, + like +
`<< ?subject1 :predicate1 << :subject2 :predicate2 :object2 >> ~ :IRIREF1 >>` + or
`<< :subject4 :predicate4 << :subject3 :predicate3 ?object3 ~ :IRIREF3 >> >>`. +

+

The example below shows a reifying triple with an implicit reifier.

+
+              VERSION "1.2"
+              PREFIX : <http://example/>
+              PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+              SELECT ?person ?authority {
+                  ?person :familyName "Smith" .
+                  << ?person :jobTitle "Designer" >> :accordingTo ?authority .
+              }
+        
+

The example below shows a reifying triple with an explicit reifier.

+
+              VERSION "1.2"
+              PREFIX : <http://example/>
+              PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+              SELECT ?person ?authority ?id {
+                  ?person :familyName "Smith" .
+                  << ?person :jobTitle "Designer" ~ ?id >> :accordingTo ?authority .
+              }
+        
+

The syntactic sugar of the example above expands to the following query.

+
+              VERSION "1.2"
+              PREFIX : <http://example/>
+              PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
+
+              SELECT ?person ?authority ?id {
+                  ?person :familyName "Smith" .
+                  ?id rdf:reifies <<( ?person :jobTitle "Designer" )>> .
+                  ?id :accordingTo ?authority .
+              }
+        
+

Note the difference in syntax between the syntactic sugar of ReifiedTriple + (i.e., `<< ... >>`) and the regular TripleTerm (i.e., `<<( ... )>>`).

+ +
+

Annotation Syntax

+

SPARQL also defines an annotation syntax + to both reify and assert a triple pattern, + which provides a convenient shortcut. + An annotation can be used to simultaneously assert a triple pattern, + via an explicit or implicit identifier, + and have that triple pattern be the + subject or + object of further triple patterns. + If explicitly identified, the same reifier can then be used as the + subject or + object of additional + triple patterns and/or triple terms. +

+

Like a ReifiedTriple, + the annotation syntax uses a reifier, written as either an + variable, IRI, or blank node, + preceded by a tilde (~), + to identify the + triple term being reified. + However, while a + ReifiedTriple + may contain at most one reifier, the annotation syntax may contain + any number of reifiers. Each reifier causes a corresponding + reifying triple to be produced. +

+

A reifier may be followed by an annotation block. + If a reifier is not followed by an annotation block, it is treated + analogously to a + ReifiedTriple + without additional annotations. + If an annotation block is not immediately preceded by a reifier, + a fresh RDF blank node is allocated to serve as the reifier of the + triple term. +

+

The annotation syntax is a syntactic shortcut in SPARQL. + The RDF Abstract Syntax [[RDF11-CONCEPTS]] does not + distinguish how the triples were written.

+

The example below shows an annotated triple pattern with an explicit reifier.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person ?authority {
+                    ?person :name "Alice" ~ :t {| :statedBy ?authority ; :recorded "2021-07-07"^^xsd:date |} .
+                }
+          
+

The syntactic sugar of the annotation syntax in the example above expands to the following query.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person ?authority {
+                    ?person :name "Alice" .
+                    << ?person :name "Alice" ~ :t >> :statedBy ?authority ;
+                                                    :recorded "2021-07-07"^^xsd:date .
+                }
+          
+

And if we fully expand this query to use TripleTerm's instead of reifiers, the query is expanded to the following.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person ?authority {
+                    ?person :name "Alice" .
+                    :t rdf:reifies <<( ?person :name "Alice" )>> .
+                    :t :statedBy ?authority .
+                    :t :recorded "2021-07-07"^^xsd:date .
+                }
+          
+

The example below shows an annotated triple pattern with an implicit reifier, for which a fresh blank node is allocated.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person ?authority {
+                    ?person :name "Alice" ~ :t {| :statedBy ?authority ; :recorded "2021-07-07"^^xsd:date |} .
+                }
+          
+

An Annotation + may include any number of annotation blocks. If such blocks are not + immediately preceded by explicit reifiers, each block is associated + with a fresh blank node allocated as its reifier, as seen in the example below.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person ?authority1 ?authority2 {
+                    ?person :name "Alice" 
+                      {| :statedBy ?authority1 ; :recorded "2021-02-01"^^xsd:date |}
+                      {| :statedBy ?authority2 ; :recorded "2021-07-07"^^xsd:date |} .
+                }
+          
+

The query above will be fully expanded to the query below, where _:b0 and _:b1 stand for fresh RDF blank nodes.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person ?authority1 ?authority2 {
+                    ?person :name "Alice" .
+                    _:b0 rdf:reifies <<( ?person :name "Alice" )>> .
+                    _:b0 :statedBy ?authority1 .
+                    _:b0 :recorded "2021-02-01"^^xsd:date .
+                    _:b1 rdf:reifies <<( ?person :name "Alice" )>> .
+                    _:b1 :statedBy ?authority2 .
+                    _:b1 :recorded "2021-07-07"^^xsd:date .
+                }
+          
+

The annotation syntax may also contain multiple explicit + reifiers without annotation blocks, as shown in the example below. Each such reifier + causes a corresponding reifying triple to be produced.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person {
+                    ?person :name "Alice" ~ :stmt1 ~ stmt2 .
+                }
+          
+

The query above will be fully expanded to the query below.

+
+                VERSION "1.2"
+                PREFIX : <http://example/>
+                PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
+          
+                SELECT ?person {
+                    ?person :name "Alice" .
+                    :stmt1 rdf:reifies <<( ?person :name "Alice" )>> .
+                    :stmt2 rdf:reifies <<( ?person :name "Alice" )>> .
+                }
+          
+
+

Version Announcement

To cope with the language evolution of SPARQL, From 3dc113f22d461ea15f3e0f7dd59d6f43d3045fa2 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 24 Jun 2026 11:32:42 +0200 Subject: [PATCH 2/3] Add changelog entry for the sections on triple terms and reifying triples --- spec/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/index.html b/spec/index.html index 546afc5..66c0c69 100644 --- a/spec/index.html +++ b/spec/index.html @@ -13290,7 +13290,7 @@

Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language

Normative changes: