-
Notifications
You must be signed in to change notification settings - Fork 4
Add SPARQL syntax sections on triple terms, reifiers, and annotations #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rubensworks
wants to merge
3
commits into
main
Choose a base branch
from
feature/syntax-tripleterms-reifiers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1369,6 +1369,262 @@ <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 may use a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a> or another <a href="#defn_TriplePattern">triple pattern</a>. | ||
| </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><<(</code>, and | ||
| followed by <code>)>></code>. | ||
| Note that <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple terms</a> and <a href="#defn_TriplePattern">triple patterns</a> | ||
| may be nested. | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| </p> | ||
| <p>The example below shows how a <a href="#defn_TriplePattern">triple pattern</a> is being used in the object position of another <a href="#defn_TriplePattern">triple pattern</a>.</p> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| <pre class="query nohighlight"> | ||
| 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 . | ||
| } | ||
| </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> | ||
| using the `rdf:reifies` <a data-cite="RDF12-CONCEPTS#dfn-predicate">predicate</a>. | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| Such a triple is called a <dfn data-cite="RDF12-CONCEPTS#dfn-reifying-triple">reifying triple</dfn>. | ||
| SPARQL provides a shorthand notation for writing <a>reifying triples</a> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| 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 a <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a>, which | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| 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><<</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>>></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>, <a href="#riri">IRI</a>, or <a href="#rBlankNode">blank node</a>. | ||
| For example, `<< :subject :predicate :object ~ :IRIREF >>`. | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| If no reifiers are present, | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| or the <code title="tilde">~</code> | ||
| is not immediately followed by <a href="#rVar">variable</a>, <a href="#riri">IRI</a>, or <a href="#rBlankNode">blank node</a>, | ||
| a fresh <a data-cite="RDF12-CONCEPTS#dfn-blank-node">RDF blank node</a> is allocated, | ||
| as with `<< :subject :predicate :object >>`, | ||
| or `<< :subject :predicate :object ~ >>`. | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| </p> | ||
| <p class="note"><a href="#rReifiedTriple"><code>ReifiedTriple</code>'s</a> may be nested, | ||
| like | ||
| <br/>`<< ?subject1 :predicate1 << :subject2 :predicate2 :object2 >> ~ :IRIREF1 >>` | ||
| or <br/>`<< :subject4 :predicate4 << :subject3 :predicate3 ?object3 ~ :IRIREF3 >> >>`. | ||
| </p> | ||
| <p>The example below shows a reifying triple with an implicit reifier.</p> | ||
| <pre class="query nohighlight"> | ||
| 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 . | ||
| } | ||
| </pre> | ||
| <p>The example below shows a reifying triple with an explicit reifier.</p> | ||
| <pre class="query nohighlight"> | ||
| 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 . | ||
| } | ||
| </pre> | ||
| <p>The syntactic sugar of the example above expands to the following query.</p> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| <pre class="query nohighlight"> | ||
| 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 . | ||
| } | ||
| </pre> | ||
| <p class="note">Note the difference in syntax between the syntactic sugar of <a href="#rReifiedTriple"><code>ReifiedTriple</code></a> | ||
| (i.e., `<< ... >>`) and the regular <a href="#rTripleTerm"><code>TripleTerm</code></a> (i.e., `<<( ... )>>`).</p> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
|
|
||
| <section id="syntaxAnnotation"> | ||
| <h3>Annotation Syntax</h3> | ||
| <p>SPARQL also defines an <dfn data-lt="annotation-syntax">annotation syntax</dfn> | ||
| to both reify and assert a <a href="#defn_TriplePattern">triple pattern</a>, | ||
|
rubensworks marked this conversation as resolved.
Outdated
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
| 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 an | ||
| <a href="#rVar">variable</a>, <a href="#riri">IRI</a>, or <a href="#rBlankNode">blank node</a>, | ||
| preceded by a tilde (<code title="tilde">~</code>), | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| to identify the | ||
| <a data-cite="RDF12-CONCEPTS#dfn-triple-term">triple term</a> being reified. | ||
| However, while a | ||
| <a href="#rReifiedTriple"><code>ReifiedTriple</code></a> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| 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> may be followed by an annotation block. | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| 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 : <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 |} . | ||
| } | ||
| </pre> | ||
| <p>The syntactic sugar of the annotation syntax in the example above expands to the following query.</p> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| <pre class="query nohighlight"> | ||
| 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 . | ||
| } | ||
| </pre> | ||
| <p>And 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> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| <pre class="query nohighlight"> | ||
| 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 . | ||
| } | ||
| </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 : <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 |} . | ||
| } | ||
| </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 : <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 |} . | ||
| } | ||
| </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 : <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 . | ||
| } | ||
| </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 : <http://example/> | ||
| PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> | ||
|
|
||
| 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 : <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" )>> . | ||
| } | ||
| </pre> | ||
| </section> | ||
| </section> | ||
| <section id="syntaxVersionAnnouncement"> | ||
| <h3>Version Announcement</h3> | ||
| <p>To cope with the language evolution of SPARQL, | ||
|
|
@@ -13034,7 +13290,7 @@ <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> | ||
|
rubensworks marked this conversation as resolved.
Outdated
|
||
| <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> | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.