From 40751ac212642d87a8cf99470dc1bd583edf4e97 Mon Sep 17 00:00:00 2001
From: Ruben Taelman 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 The example below shows how a triple pattern is being used in the object position of another triple pattern. 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 rdf:type
+ Triple Terms
+ TripleTerm with
+ TripleTermSubject,
+ Verb, and
+ TripleTermObject, all
+ preceded by <<(, and
+ followed by )>>.
+ Note that triple terms and triple patterns
+ may be nested.
+
+ 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
+ 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., `<<( ... )>>`).
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" )>> .
+ }
+
+ To cope with the language evolution of SPARQL,
From 3dc113f22d461ea15f3e0f7dd59d6f43d3045fa2 Mon Sep 17 00:00:00 2001
From: Ruben Taelman Within the object position of a triple pattern,
- we may use a triple term or another triple pattern.
+ we can use a triple term
+ or another triple pattern.
Such a triple pattern or nested triple pattern
is represented as a Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language
Normative changes:
rdf:type
Triple Terms
TripleTerm with
@@ -1382,9 +1383,10 @@ Triple Terms
preceded by <<(, and
followed by )>>.
Note that triple terms and triple patterns
- may be nested.
+ can be nested.
The example below shows how a triple pattern is being used in the object position of another triple pattern.
+The example below shows how a triple pattern + can be used in the object position of another triple pattern.
VERSION "1.2"
PREFIX : <http://example/>
@@ -1401,9 +1403,9 @@ Triple Terms
Reifying Triples
Triple terms are mostly used
as the object of a triple
- using the `rdf:reifies` predicate.
+ with a predicate of `rdf:reifies`.
Such a triple is called a reifying triple.
- SPARQL provides a shorthand notation for writing reifying triples
+ SPARQL also provides a shorthand notation for writing reifying triples
using the ReifiedTriple grammar production.
A ReifiedTriple
@@ -1412,7 +1414,7 @@
Reifying Triples
identifier (reifier)
and a triple term.
The identifier becomes a way to indirectly refer
- to a triple term, which
+ to the triple term, which
may or may not be asserted within the query.
Reification using triple terms is a concept distinct from the
@@ -1433,14 +1435,15 @@
Reifying Triples
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,
+ a variable, an IRI, or a blank node;
+ for example, `<< :subject :predicate :object ~ :IRIREF >>`.
+ If no reifier is 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 ~ >>`.
+ is not immediately followed by variable,
+ an IRI, or a blank node —
+ as in `<< :subject :predicate :object >>`,
+ or `<< :subject :predicate :object ~ >>` —
+ a fresh RDF blank node is allocated.
ReifiedTriple's may be nested,
like
@@ -1469,7 +1472,7 @@
Reifying Triples
<< ?person :jobTitle "Designer" ~ ?id >> :accordingTo ?authority .
}
- The syntactic sugar of the example above expands to the following query.
+The syntactic sugar of the example above expands to the following query:
VERSION "1.2"
PREFIX : <http://example/>
@@ -1481,13 +1484,14 @@ Reifying Triples
?id :accordingTo ?authority .
}
- Note the difference in syntax between the syntactic sugar of ReifiedTriple
- (i.e., `<< ... >>`) and the regular TripleTerm (i.e., `<<( ... )>>`).
Note the subtle difference in syntax between the syntactic sugar of
+ the ReifiedTriple (i.e., `<< ... >>`)
+ and the regular TripleTerm (i.e., `<<( ... )>>`).
SPARQL also defines an annotation syntax - to both reify and assert a triple pattern, + that both reifies and asserts 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, @@ -1500,18 +1504,18 @@
Like a ReifiedTriple,
- the annotation syntax uses a reifier, written as either an
- variable, IRI, or blank node,
- preceded by a tilde (~),
+ the annotation syntax uses a reifier — written as either a
+ variable, an IRI, or a blank node,
+ preceded by a tilde (~) —
to identify the
triple term being reified.
- However, while a
- ReifiedTriple
+ However, while the
+ ReifiedTriple syntax
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. +
A reifier can be followed by an annotation block.
If a reifier is not followed by an annotation block, it is treated
analogously to a
ReifiedTriple
@@ -1533,7 +1537,7 @@
The syntactic sugar of the annotation syntax in the example above expands to the following query.
+The syntactic sugar of the annotation syntax in the example above expands to the following query:
VERSION "1.2"
PREFIX : <http://example/>
@@ -1545,7 +1549,8 @@ Annotation Syntax
: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.
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/>
@@ -13290,7 +13295,9 @@ Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language
Normative changes: