Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
265 changes: 264 additions & 1 deletion spec/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1369,6 +1369,267 @@ <h4>rdf:type</h4>
</pre>
</section>
</section>
<section id="syntaxTripleTerms">
<h3>Triple Terms</h3>
<p>Within the object position of a <a href="#defn_TriplePattern">triple pattern</a>,
we can use a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>
or another <a href="#defn_TriplePattern">triple pattern</a>.
Comment on lines +1375 to +1376

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got a bit confused by this sentence because it puts at the same level a RDF term and the pattern for a triple that is not a term.

What about something like

Suggested change
we can use a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>
or another <a href="#defn_TriplePattern">triple pattern</a>.
we can use a triple term pattern.

and then define what this "triple term pattern" is.

Also, imho no need to mention plain "triple term"s, they can be seen as a special case of triple term patterns.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Special cases" are easily glossed over or misunderstood by new readers. Therefore, to my mind, such "special cases" should almost always be explicitly stated, if they're intended to be understood by such new readers. So, if we accept the edit above, and then 'define what this "triple term pattern" is', that definition should include explicit mention of the special case.

</p>
<p>Such a <a href="#defn_TriplePattern">triple pattern</a> or nested <a href="#defn_TriplePattern">triple pattern</a>
is represented as a <a href="#rTripleTerm"><code>TripleTerm</code></a> with
<a href="#rTripleTermSubject"><code>TripleTermSubject</code></a>,
<a href="#rVerb"><code>Verb</code></a>, and
<a href="#rTripleTermObject"><code>TripleTermObject</code></a>, all
preceded by <code>&lt;&lt;(</code>, and
followed by <code>)&gt;&gt;</code>.
Note that <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> and <a href="#defn_TriplePattern">triple patterns</a>
can be nested.
</p>
<p>The example below shows how a <a href="#defn_TriplePattern">triple pattern</a>
can be used in the object position of another <a href="#defn_TriplePattern">triple pattern</a>.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;

SELECT ?person ?authority {
?person :familyName "Smith" .
_:anno rdf:reifies &lt;&lt;( ?person :jobTitle "Designer" )&gt;&gt; .
_:anno :accordingTo ?authority .
}
</pre>
</section>
<section id="syntaxReifyingTriples">
<h3>Reifying Triples</h3>
<p><a data-cite="RDF12-CONCEPTS#dfn-triple-term">Triple terms</a> are mostly used
as the <a data-cite="RDF12-CONCEPTS#dfn-object">object</a> of a <a data-cite="RDF12-CONCEPTS#dfn-rdf-triple">triple</a>
with a <a data-cite="RDF12-CONCEPTS#dfn-predicate">predicate</a> of `rdf:reifies`.
Such a triple is called a <dfn data-cite="RDF12-CONCEPTS#dfn-reifying-triple">reifying triple</dfn>.
SPARQL also provides a shorthand notation for writing <a>reifying triples</a>
using the <a href="#rReifiedTriple"><code>ReifiedTriple</code></a> grammar production.</p>
</p>
<p>A <a href="#rReifiedTriple"><code>ReifiedTriple</code></a>
provides syntactic sugar to represent a <a>reifying triple</a>,
which defines a specific relationship between an
identifier (<dfn data-cite="RDF12-CONCEPTS#dfn-reifier">reifier</dfn>)
and a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>.
The identifier becomes a way to indirectly refer
to the <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>, which
may or may not be asserted within the query.
</p>
<p class="note">Reification using triple terms is a concept distinct from the
<a data-cite="RDF12-SEMANTICS#Reif">Reification vocabulary</a> originally
defined in <a data-cite="RDF-MT#Reif">RDF Semantics</a>.
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 <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>
using the `rdf:reifies` predicate.
</p>
<p>A <a>reifying triple</a> is represented using the
<a href="#rReifiedTriple"><code>ReifiedTriple</code></a> production
starting with <code>&lt;&lt;</code>,
followed by a <a href="#rReifiedTripleSubject"><code>ReifiedTripleSubject</code></a>,
a <a href="#rVerb"><code>Verb</code></a>, and
a <a href="#rReifiedTripleObject"><code>ReifiedTripleObject</code></a>,
followed by an optional <a href="#rReifier"><code>Reifier</code></a>,
and ending with <code>&gt;&gt;</code>.
This <a href="#rReifier"><code>Reifier</code></a> is composed of a <code title="tilde">~</code>
followed by an optional <a href="#rVarOrReifierId"><code>rVarOrReifierId</code></a> production.
This <a href="#rVarOrReifierId"><code>rVarOrReifierId</code></a> is composed of
a <a href="#rVar">variable</a>, an <a href="#riri">IRI</a>, or a <a href="#rBlankNode">blank node</a>;
for example, `&lt;&lt; :subject :predicate :object ~ :IRIREF &gt;&gt;`.
If no reifier is present,
or the <code title="tilde">~</code>
is not immediately followed by <a href="#rVar">variable</a>,
an <a href="#riri">IRI</a>, or a <a href="#rBlankNode">blank node</a> —
as in `&lt;&lt; :subject :predicate :object &gt;&gt;`,
or `&lt;&lt; :subject :predicate :object ~ &gt;&gt;` —
a fresh <a data-cite="RDF12-CONCEPTS#dfn-blank-node">RDF blank node</a> is allocated.
</p>
<p class="note"><a href="#rReifiedTriple"><code>ReifiedTriple</code>'s</a> may be nested,
like
<br/>`&lt;&lt; ?subject1 :predicate1 &lt;&lt; :subject2 :predicate2 :object2 &gt;&gt; ~ :IRIREF1 &gt;&gt;`
or <br/>`&lt;&lt; :subject4 :predicate4 &lt;&lt; :subject3 :predicate3 ?object3 ~ :IRIREF3 &gt;&gt; &gt;&gt;`.
</p>
<p>The example below shows a reifying triple with an implicit reifier.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;

SELECT ?person ?authority {
?person :familyName "Smith" .
&lt;&lt; ?person :jobTitle "Designer" &gt;&gt; :accordingTo ?authority .
}
</pre>
<p>The example below shows a reifying triple with an explicit reifier.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;

SELECT ?person ?authority ?id {
?person :familyName "Smith" .
&lt;&lt; ?person :jobTitle "Designer" ~ ?id &gt;&gt; :accordingTo ?authority .
}
</pre>
<p>The syntactic sugar of the example above expands to the following query:</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX rdf: &lt;http://www.w3.org/1999/02/22-rdf-syntax-ns#&gt;

SELECT ?person ?authority ?id {
?person :familyName "Smith" .
?id rdf:reifies &lt;&lt;( ?person :jobTitle "Designer" )&gt;&gt; .
?id :accordingTo ?authority .
}
</pre>
<p class="note">Note the subtle difference in syntax between the syntactic sugar of
the <a href="#rReifiedTriple"><code>ReifiedTriple</code></a> (i.e., `&lt;&lt; ... >>`)
and the regular <a href="#rTripleTerm"><code>TripleTerm</code></a> (i.e., `&lt;&lt;( ... )>>`).</p>

<section id="syntaxAnnotation">
<h3>Annotation Syntax</h3>
<p>SPARQL also defines an <dfn data-lt="annotation-syntax">annotation syntax</dfn>
that both reifies and asserts a <a href="#defn_TriplePattern">triple pattern</a>,
Comment on lines +1493 to +1494

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are patterns "reified" or "asserted"? I think it's more natural to think of annotation syntax as representing patterns which match reified and asserted data.

@kasei Good point. What do you think of the following?

Suggested change
<p>SPARQL also defines an <dfn data-lt="annotation-syntax">annotation syntax</dfn>
that both reifies and asserts a <a href="#defn_TriplePattern">triple pattern</a>,
<p>SPARQL also defines an <dfn data-lt="annotation-syntax">annotation syntax</dfn>
to represent <a href="#defn_TriplePattern">triple patterns</a> that match reified and asserted triples,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this obscures the point of this sentence, that SPARQL's annotation syntax simultaneously reifies and asserts. Trying to fix that, starting with the edit above --

Suggested change
<p>SPARQL also defines an <dfn data-lt="annotation-syntax">annotation syntax</dfn>
that both reifies and asserts a <a href="#defn_TriplePattern">triple pattern</a>,
<p>SPARQL also defines an <dfn data-lt="annotation-syntax">annotation syntax</dfn>
to represent <a href="#defn_TriplePattern">triple patterns</a> that simultaneously
match reified and asserted triples,

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
<a data-cite="RDF12-CONCEPTS#dfn-subject">subject</a> or
<a data-cite="RDF12-CONCEPTS#dfn-object">object</a> of further triple patterns.
If explicitly identified, the same <a>reifier</a> can then be used as the
<a data-cite="RDF12-CONCEPTS#dfn-subject">subject</a> or
<a data-cite="RDF12-CONCEPTS#dfn-object">object</a> of additional
triple patterns and/or <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a>.
</p>
<p>Like a <a href="#rReifiedTriple"><code>ReifiedTriple</code></a>,
the annotation syntax uses a <a>reifier</a> — written as either a
<a href="#rVar">variable</a>, an <a href="#riri">IRI</a>, or a <a href="#rBlankNode">blank node</a>,
preceded by a tilde (<code title="tilde">~</code>) —
to identify the
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a> being reified.
However, while the
<a href="#rReifiedTriple"><code>ReifiedTriple</code></a> syntax
may contain at most one <a>reifier</a>, the annotation syntax may contain
any number of <a>reifiers</a>. Each <a>reifier</a> causes a corresponding
reifying triple to be produced.
</p>
<p>A <a>reifier</a> can be followed by an annotation block.
If a <a>reifier</a> is not followed by an annotation block, it is treated
analogously to a
<a href="#rReifiedTriple"><code>ReifiedTriple</code></a>
without additional annotations.
If an annotation block is not immediately preceded by a <a>reifier</a>,
a fresh RDF blank node is allocated to serve as the <a>reifier</a> of the
<a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>.
</p>
<p class="note">The annotation syntax is a syntactic shortcut in SPARQL.
The RDF Abstract Syntax [[RDF11-CONCEPTS]] does not
distinguish how the triples were written.</p>
<p>The example below shows an annotated triple pattern with an explicit reifier.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person ?authority {
?person :name "Alice" ~ :t {| :statedBy ?authority ; :recorded "2021-07-07"^^xsd:date |} .
}
</pre>
<p>The syntactic sugar of the annotation syntax in the example above expands to the following query:</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person ?authority {
?person :name "Alice" .
&lt;&lt; ?person :name "Alice" ~ :t &gt;&gt; :statedBy ?authority ;
:recorded "2021-07-07"^^xsd:date .
}
</pre>
<p>If we fully expand this query to use <a href="#rTripleTerm"><code>TripleTerm</code>'s</a> instead of reifiers,
the query is expanded to the following:</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person ?authority {
?person :name "Alice" .
:t rdf:reifies &lt;&lt;( ?person :name "Alice" )&gt;&gt; .
:t :statedBy ?authority .
:t :recorded "2021-07-07"^^xsd:date .
}
</pre>
<p>The example below shows an annotated triple pattern with an implicit reifier, for which a fresh blank node is allocated.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person ?authority {
?person :name "Alice" ~ :t {| :statedBy ?authority ; :recorded "2021-07-07"^^xsd:date |} .
}
</pre>
<p>An <a href="#rAnnotation"><code>Annotation</code></a>
may include any number of annotation blocks. If such blocks are not
immediately preceded by explicit <a>reifiers</a>, each block is associated
with a fresh blank node allocated as its <a>reifier</a>, as seen in the example below.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person ?authority1 ?authority2 {
?person :name "Alice"
{| :statedBy ?authority1 ; :recorded "2021-02-01"^^xsd:date |}
{| :statedBy ?authority2 ; :recorded "2021-07-07"^^xsd:date |} .
}
</pre>
<p>The query above will be fully expanded to the query below, where <code>_:b0</code> and <code>_:b1</code> stand for fresh RDF blank nodes.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person ?authority1 ?authority2 {
?person :name "Alice" .
_:b0 rdf:reifies &lt;&lt;( ?person :name "Alice" )&gt;&gt; .
_:b0 :statedBy ?authority1 .
_:b0 :recorded "2021-02-01"^^xsd:date .
_:b1 rdf:reifies &lt;&lt;( ?person :name "Alice" )&gt;&gt; .
_:b1 :statedBy ?authority2 .
_:b1 :recorded "2021-07-07"^^xsd:date .
}
</pre>
<p>The annotation syntax may also contain multiple explicit
<a>reifiers</a> without annotation blocks, as shown in the example below. Each such <a>reifier</a>
causes a corresponding reifying triple to be produced.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person {
?person :name "Alice" ~ :stmt1 ~ stmt2 .
}
</pre>
<p>The query above will be fully expanded to the query below.</p>
<pre class="query nohighlight">
VERSION "1.2"
PREFIX : &lt;http://example/&gt;
PREFIX xsd: &lt;http://www.w3.org/2001/XMLSchema#&gt;

SELECT ?person {
?person :name "Alice" .
:stmt1 rdf:reifies &lt;&lt;( ?person :name "Alice" )&gt;&gt; .
:stmt2 rdf:reifies &lt;&lt;( ?person :name "Alice" )&gt;&gt; .
}
</pre>
</section>
</section>
<section id="syntaxVersionAnnouncement">
<h3>Version Announcement</h3>
<p>To cope with the language evolution of SPARQL,
Expand Down Expand Up @@ -13034,7 +13295,9 @@ <h2>Changes between SPARQL 1.1 Query Language and SPARQL 1.2 Query Language</h2>
Normative changes:
<ul>
<li>Update grammar for triple terms, reifiers, reified triples, annotation syntax, and triple term functions
in <a href="#sparqlGrammar" class="sectionRef"></a></li>
in <a href="#sparqlGrammar" class="sectionRef"></a> and explain them
in <a href="#syntaxTripleTerms" class="sectionRef"></a>
and <a href="#syntaxReifyingTriples" class="sectionRef"></a></li>
<li>Add functions related to <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> to
<a href="#func-triple-terms" class="sectionRef"></a>:
`TRIPLE`, `isTRIPLE`, `SUBJECT`, `PREDICATE`, `OBJECT`</li>
Expand Down
Loading