Copyright © 2022 the Contributors to the RDF-star and SPARQL-star Specification, published by the RDF-DEV Community Group under the W3C Community Contributor License Agreement (CLA) . A human-readable summary is available.
The Resource Description Framework (RDF) is a general-purpose framework for representing information on the Web. RDF-star extends RDF with a convenient way to make statements about other statements. This specification defines the abstract syntax of RDF-star as an extension of RDF's. It extends a number of RDF concrete syntaxes to support the new abstract syntax. It also extends RDF's formal semantics. Finally, this specification extends the SPARQL language to allow querying and updating of RDF-star data.
This specification was published by the RDF-DEV Community Group . It is not a W3C Standard nor is it on the W3C Standards Track. Please note that under the W3C Community Contributor License Agreement (CLA) there is a limited opt-out and other conditions apply. Learn more about W3C Community and Business Groups .
GitHub Issues are preferred for discussion of this specification. Alternatively, you can send comments to our mailing list. Please send them to public-rdf-star@w3.org ( subscribe , archives ).
This section is non-normative.
The RDF data model lets you state facts in three-part subject-predicate-object statements known as triples. For example, with a single RDF triple, you can say that employee38 has a familyName of "Smith". A triple's predicate is a property specified with an IRI (an Internationalized version of a URI), identifying that property in a globally unambiguous way. A triple's subject and object can each be an IRI referencing any entity, and the object can also be a literal value such as "Smith" or data of other types such as dates, numbers, or Boolean values.
Sometimes, we want the subject or object of a triple to refer to another triple. For example, the statement "according to employee22, employee38 has a jobTitle of 'Assistant Designer'" can be modeled as a triple with "according to" as its predicate, employee22 as its object, and another triple as its subject, namely the triple "employee38 has a jobTitle of 'Assistant Designer'". This use of a triple as the subject or object resource of another triple so that we can say things about that triple is known as reification . The concept of reification has always been part of RDF, but expressing it in most RDF concrete syntaxes such as Turtle and N-Triples, as well as processing or querying it with SPARQL, has been verbose and cumbersome [ RDF-STAR-FOUNDATION ].
This section is non-normative.
This specification describes RDF-star, an extension of RDF's conceptual data model and concrete syntaxes, which provides a compact alternative to standard RDF reification . This model and its syntaxes enable the creation of concise triples that reference other triples as subject and object resources. Triples that include a triple as a subject or an object are known as RDF-star triples . The following dataset shows the example RDF-star triples from above using the Turtle-star syntax, which uses double angle brackets to enclose a triple serving as a subject or object resource:
PREFIX : <http://www.example.org/> :employee38 :familyName "Smith" . << :employee38 :jobTitle "Assistant Designer" >> :accordingTo :employee22 .
After declaring a prefix so that IRIs can be abbreviated, the first triple in this example asserts that employee38 has a familyName of "Smith". Note that this dataset does not assert that employee38 has a jobTitle of "Assistant Designer"; it says that employee22 has made that claim. In other words, the triple "employee38 has a jobTitle of 'Assistant Designer'" is not what we call an asserted triple , like "employee38 has a familyName of 'Smith'" above; rather, it is known as a quoted triple .
If
we
added
the
triple
:employee38
:jobTitle
"Assistant
Designer"
to
the
example
above,
then
this
triple
about
employee38's
jobTitle
would
be
both
a
quoted
and
an
asserted
triple.
This
pattern
is
quite
common,
so
Turtle-star
offers
a
dedicated
syntax
for
it,
called
the
annotation
syntax
,
illustrated
in
Example
2
below.
Note
that
this
construct
is
purely
syntactic
sugar,
as
it
can
be
expanded
using
only
the
double
angle
brackets.
PREFIX : <http://www.example.org/>
:employee38
:familyName "Smith" ;
:jobTitle "Assistant Designer" {| :accordingTo :employee22 |} .
# this is equivalent to:
#
# :employee38 :familyName "Smith" .
# :employee38 :jobTitle "Assistant Designer" .
#
<<
:employee38
:jobTitle
"Assistant
Designer"
>>
:accordingTo
:employee22
.
This specification also describes an extension to the SPARQL Protocol and Query Language known as SPARQL-star for the querying of RDF-star triples. For example, the following SPARQL-star query asks "who has made any claims about employee38?"
PREFIX : <http://www.example.org/>
SELECT ?claimer WHERE {
<< :employee38 ?property ?value >> :accordingTo ?claimer
}
SPARQL can also be used to update RDF data, and SPARQL-star also extends that part. For example, the following SPARQL-star adds all the statements made by employee22 about employee38 as asserted triples , annotating them as "confirmed".
PREFIX : <http://www.example.org/>
INSERT {
:employee38 ?p ?o {| :status "confirmed" |}
} WHERE {
<< :employee38 ?p ?o >> :accordingTo :employee22
}
People coming to RDF-star may have wrong ideas about what it is or how to use it. The purpose of this section is to dispel the most common misconceptions.
RDF-star is not syntactic sugar for standard reification . While the latter is a vocabulary that fits into the standard RDF model (abstract syntax), RDF-star extends that model (see 2. Concepts and Abstract Syntax ) with a new construct, namely quoted triples . Note also that the two are not mutually exclusive: standard reification can be used in conjunction with RDF-star.
Unlike
reified
statements,
RDF-star
quoted
triples
are
unique:
wherever
<<
:employee38
:jobTitle
"Assistant
Designer"
>>
appears,
it
always
denotes
one
and
the
same
thing.
This
impacts
the
modeling
choices
one
has
to
make
when
using
RDF-star;
this
is
further
discussed
in
2.3
Triples
and
occurrences
.
Finally, quoted triples are referentially opaque. This means that two quoted triples containing distinct but equivalent terms (i.e., coreferences, known to denote the same thing) are nonetheless considered to be different triples. 6.4.4 Referential opacity and the following sections discuss the rationale for this design, and how some form of referential transparency can still be added to RDF-star if and when needed.
For the remainder of this document, examples will assume that the following prefixes have been declared to represent the IRIs shown with them here:
:
|
<http://www.example.org/>
|
rdf:
|
<http://www.w3.org/1999/02/22-rdf-syntax-ns#>
|
rdfs:
|
<http://www.w3.org/2000/01/rdf-schema#>
|
owl:
|
<http://www.w3.org/2002/07/owl#>
|
prov:
|
<http://www.w3.org/ns/prov#>
|
dbo:
|
<http://dbpedia.org/ontology/>
|
dbr:
|
<http://dbpedia.org/resource/>
|
dc:
|
<http://purl.org/dc/elements/1.1/>
|
dct:
|
<http://purl.org/dc/terms/>
|
rdf-star:
|
<http://www.w3.org/ns/rdf-star#>
|
This specification covers many aspects of RDF-star, and not all sections will be of interest to all readers.
Section 2 first defines the concepts and the abstract syntax of RDF-star, to which all following sections refer. The next three sections focus on how users will interact with the abstract syntax, defining the concrete syntaxes , the query language SPARQL-star and its counterpart for updates . Section 6 then defines RDF-star's formal semantics, which lays the foundation for reasoning with RDF-star data. Finally, Section 7 defines an RDF vocabulary capturing the main concepts of RDF-star.
|
2.
Concepts
and
Abstract
Syntax
can be... | ||
|
...
serialized
with
3. Concrete Syntaxes |
...
represented
by
7. RDF-star vocabulary | |
|
...
updated
with
5. SPARQL-star Update |
...
interpreted
through
6. RDF-star Semantics |
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MAY , MUST , MUST NOT , and OPTIONAL in this document are to be interpreted as described in BCP 14 [ RFC2119 ] [ RFC8174 ] when, and only when, they appear in all capitals, as shown here.
A system supports RDF-star for input if it supports an input syntax for an RDF 1.1 standard syntax that has additional syntax for quoted triples . Such input syntaxes include those in the RDF-star test suite ( N-Triples-star syntax tests , Turtle-star syntax tests , or TriG-star syntax tests ).
A system supports RDF-star for output if it supports an output syntax for an RDF 1.1 standard syntax that has additional syntax for quoted triples . Such output syntaxes include those in the RDF-star test suite ( N-Triples-star syntax tests , Turtle-star syntax tests , or TriG-star syntax tests ).
A system supports SPARQL-star if it passes the SPARQL-star syntax test suite and the SPARQL-star evaluation test suites.
In the following, we introduce a number of definitions specific to SPARQL-star, which rely on the following notions (extending some of them) defined in RDF 1.1 Concepts and Abstract Syntax [ RDF11-CONCEPTS ]: blank node , default graph , graph name , IRI , literal , named graphs , subject , predicate , object , RDF dataset , RDF graph , RDF triple , and RDF term .
An RDF-star graph is a set of RDF-star triples .
An RDF-star triple is a 3-tuple defined recursively as follows:
As for RDF triples , we call the 3 components of an RDF-star triple its subject , predicate and object , respectively. From the definitions above, it follows that any RDF graph is also an RDF-star graph . Note also that, by definition, an RDF-star triple cannot contain itself and cannot be nested infinitely.
IRIs , literals , blank nodes and RDF-star triples are collectively known as RDF-star terms .
For every RDF-star triple t , we define its constituent terms (or simply constituents) as the set containing its subject , its predicate , its object , plus all the constituent terms of its subject and/or its object if they are themselves RDF-star triples . By extension, we define the constituent terms of an RDF-star graph to be the union set of the constituent terms of all its triples.
<< _:a :name "Alice" >> :statedBy :bob.
:name
,
:statedBy
,
:bob
,
the
blank
node
_:a
,
the
literal
"Alice"
,
and
the
triple
<<
_:a
:name
"Alice"
>>
.
An RDF-star triple used as the subject or object of another RDF-star triple is called a quoted triple . An RDF-star triple that is an element of an RDF-star graph is called an asserted triple . Note that, in a given RDF-star graph , the same triple MAY be both quoted and asserted .
An RDF-star dataset is a collection of RDF-star graphs , and comprises:
Again, this definition is an extension of the notion of RDF dataset , hence it follows that any RDF dataset is also an RDF-star dataset .
This section is non-normative.
A triple in RDF is a tuple of three components: subject, predicate, and object. These are collectively known as RDF Terms as defined in [ RDF11-CONCEPTS ].
RDF-star introduces quoted triple , which is a new kind of RDF term. A quoted triple is a triple used as the subject or object of another triple. Quoted triples can also be called "embedded triples".
in RDF 1.1, an asserted triple is an element of the set of triples that make up an RDF graph . RDF-star does not change this except that an RDF-star triple can contain quoted triples. A triple can be used as an asserted triple , a quoted triple , or both, in a given graph.
A
quoted
triple
is
written
in
Turtle-star
and
related
syntaxes
using
delimiters
<<
and
>>
.
<<
:a
:name
"Alice"
>>
The
definition
of
quoted
triple
is
recursive.
That
is,
a
quoted
triple
can
itself
have
a
subject
or
object
component
which
is
another
quoted
triple.
Cycles
of
quoted
triples
can
not
be
created.
In
the
next
example,
there
is
a
quoted
triple
with
property
:reportedBy
,
whose
subject
is
another
quoted
triple,
:a
:name
"Alice"
.
<<
<<
:a
:name
"Alice"
>>
:reportedBy
:charlie
>>
It may be apt to draw a parallel between "quoted" triples and quoted expressions in the programming language Lisp . Expressions in Lisp (called "s-expressions") are interpreted through a process called "evaluation", and as a result they have a value. A quoted expression evaluates to the expression itself - you can imagine that quoting prevents the expression from being evaluated. In RDF (as well as in RDF-star), asserting a triple (i.e., considering it to be "true") serves as the analogue of evaluation. Triples are asserted, unless (in RDF-star) they are quoted which, effectively, prevents the triple from being asserted - thus a quoted triple stands by itself and we assign no truth value to it.
Obviously this way of thinking is helpful only if you understand how Lisp works.
In
the
example
below,
there
is
a
quoted
triple,
:a
:name
"Alice"
,
which
is
used
as
the
subject
for
an
asserted
triple:
PREFIX : <http://www.example.org/> :bob :name "Bob" . << :a :name "Alice" >> :statedBy :bob .
The graph of this example has two asserted triples:
:bob
:name
"Bob"
.
<<
:a
:name
"Alice"
>>
:statedBy
:bob
.
This
graph
does
not
have
an
asserted
triple,
:a
:name
"Alice"
,
because
that
triple
is
not
an
element
of
the
set
of
triples.
On
the
other
hand,
the
graph
in
the
example
below
contains
three
asserted
triples:
the
same
two
as
the
previous
example,
and
:a
:name
"Alice"
.
The
latter
is
used
both
as
an
asserted
triple
and
a
quoted
triple
in
this
graph.
PREFIX : <http://www.example.org/> :bob :name "Bob" . :a :name "Alice" . << :a :name "Alice" >> :statedBy :bob .
This section is non-normative.
According to the definitions above, an RDF-star triple is an abstract entity whose identity is entirely defined by its subject, predicate, and object. Conversely, given three RDF-star terms s , p , and o , there is exactly and only one RDF-star triple with subject s , predicate p , and object o . This unique triple ( s , p , o ) can be quoted as the subject or object of multiple other triples, but must be assumed to represent the same thing everywhere it occurs, just like the same IRI p is assumed to represent the same thing everywhere it occurs.
In
some
situations,
however,
it
might
be
necessary
to
distinguish
the
occurrences
of
a
triple
in
different
graphs.
Consider
the
following
sentence:
"The
triple
<http://example.org/s>
<http://example.org/p>
<http://example.org/o>
in
(the
graph
represented
by)
file1.ttl
was
added
by
Alice,
and
the
same
triple
in
file2.ttl
was
added
by
Bob."
Note
that
the
words
"same
triple"
in
this
sentence
may
be
confusing,
because
although
the
triple
(as
an
abstract
entity)
is
the
same,
its
respective
occurrences
are
different
things,
each
within
a
different
file
and
with
a
different
author
(this
is
known,
in
philosophy
and
linguistics,
as
the
type-token
distinction
).
As
the
quoted
triple
represents
a
unique
thing,
adequately
conveying
the
meaning
of
the
sentence
above
requires
additional
nodes
for
representing
the
two
distinct
occurrences.
One
possible
solution
is
illustrated
in
the
following
example
(using
the
Turtle-star
concrete
syntax
described
in
the
next
section
).
_:a :occurrenceOf << :s :p :o >> ;
:in <file1.ttl> ;
dct:creator :alice.
_:b :occurrenceOf << :s :p :o >> ;
:in <file2.ttl> ;
dct:creator
:bob.
This section defines the following concrete syntaxes:
Changes for SPARQL-star are given in 4.2 Grammar and the changes for the result set formats in 4.7 Query Result Formats .
There
are
syntax
additions
for
quoted
triples
and
also
for
annotation
syntax
which
provides
a
convenient
shortcut
in
Turtle-star
and
TriG-star
syntaxes.
It
is
used
to
both
assert
a
triple
and
have
that
triple
be
the
subject
of
further
triples.
It
uses
delimiters
{|
and
|}
following
an
asserted
triple
to
make
that
triple,
as
a
quoted
triple
,
the
subject
of
the
RDF-star
triples
formed
by
combining
it
with
the
enclosed
RDF
predicate(s)
and
object(s).
Annotation syntax does not appear in the RDF-star abstract data model. It is only a syntactic short cut and the RDF-star abstract data model does not distinguished how the triples were written.
:a
:name
"Alice"
{|
:statedBy
:bob
;
:recorded
"2021-07-07"^^xsd:date
|}
.
is the same set of triples as:
<< :a :name "Alice" >> :statedBy :bob . << :a :name "Alice" >> :recorded "2021-07-07"^^xsd:date . :a :name "Alice"
and RDF-star graph contains three asserted triples.
In this section, we present Turtle-star, an extension of the Turtle format [ TURTLE ] allowing the representation of RDF-star graphs . For the sake of conciseness, we only describe here the differences between Turtle-star and Turtle.
Turtle-star is defined to follow the same grammar as Turtle, except for the EBNF productions specified below, which replace the productions having the same number (if any) in the original grammar.
| [8] |
objectList
|
::= |
object
annotation
?
(
','
object
annotation
?
)*
|
| [10] |
subject
|
::= |
iri
|
BlankNode
|
collection
|
quotedTriple
|
| [12] |
object
|
::= |
iri
|
BlankNode
|
collection
|
blankNodePropertyList
|
literal
|
quotedTriple
|
| [27t] |
quotedTriple
|
::= |
'<<'
qtSubject
verb
qtObject
'>>'
|
| [28t] |
qtSubject
|
::= |
iri
|
BlankNode
|
quotedTriple
|
| [29t] |
qtObject
|
::= |
iri
|
BlankNode
|
literal
|
quotedTriple
|
| [30t] |
annotation
|
::= |
'{|'
predicateObjectList
'|}'
|
The complete grammar may be found in C.1 Turtle-Star EBNF Grammar .
The
changes
are
that
subject
and
object
productions
have
been
extended
to
accept
quoted
triples
,
which
are
described
by
the
new
productions
27t
to
30t
.
Note
that
quoted
triples
accept
a
more
restricted
range
of
subject
and
object
expressions
than
asserted
triples
.
Additionally,
the
objectList
production
now
accepts
an
optional
annotation
after
each
object
.
A Turtle-star parser is similar to a Turtle parser as defined in Section 7 of the Turtle specification [ TURTLE ], with an additional item in its state :
qtObject
production.
Additionally, the curSubject can be bound to any RDF-star term (including a quoted triple ).
A
Turtle-star
document
defines
an
RDF-star
graph
composed
of
a
set
of
RDF-star
triples
.
The
subject
and
qtSubject
productions
set
the
curSubject
.
The
verb
production
sets
the
curPredicate
.
The
object
and
qtObject
productions
set
the
curObject
.
Finishing
the
object
production,
an
RDF-star
triple
curSubject
curPredicate
curObject
is
produced
(added
to
the
RDF-star
graph
).
Beginning
the
quotedTriple
production
records
the
curSubject
and
curPredicate
.
Finishing
the
quotedTriple
production
yields
the
RDF-star
triple
curSubject
curPredicate
curObject
and
restores
the
recorded
values
of
curSubject
and
curPredicate
.
Beginning
the
annotation
production
records
the
curSubject
and
curPredicate
,
and
sets
the
curSubject
to
the
RDF-star
triple
curSubject
curPredicate
curObject
.
Finishing
the
annotation
production
restores
the
recorded
values
of
curSubject
and
curPredicate
.
All other productions MUST be handled as specified by Section 7 of the Turtle specification [ TURTLE ], while still applying the changes above recursively.
This section is non-normative.
This section describes parser behavior when parsing a Turtle-star document that contains quoted triples and annotations .
Consider a Turtle-star document that describes an RDF triple, and also uses that triple as a quoted triple as the subject of another RDF-star triple:
BASE <http://example.org/>
PREFIX : <#>
_:a :name "Alice" .
<<
_:a
:name
"Alice"
>>
:statedBy
:bob
.
The
usual
process
of
parsing
a
Turtle
document
applies
with
the
addition
of
matching
the
quoted
triple
<<
_:a
:name
"Alice"
>>
as
part
of
the
subject
production.
The
resulting
RDF-star
graph
consists
of
two
RDF-star
triples:
http://example.org/#name
,
"Alice"
),
where
b
is
a
blank
node
http://example.org/#name
,
"Alice"
),
http://example.org/#statedBy
,
http://example.org/#bob/
),
where
b
is
the
same
blank
node
Because
the
above
example
includes
the
triple
(
b
,
http://example.org/#name
,
"Alice"
)
as
an
asserted
triple
,
the
same
RDF-star
graph
may
also
be
represented
by
using
the
Turtle-star
annotation
syntax
as
follows:
BASE <http://example.org/>
PREFIX : <#>
_:a
:name
"Alice"
{|
:statedBy
:bob
|}
.
In
this
case,
the
objectList
production
matches
the
annotation
production
on
{|
:source
:bob
|}
after
parsing
the
object
production
on
"Alice"
.
At
this
point,
the
curSubject
,
curPredicate
,
and
curObject
are
saved,
and
a
new
RDF-star
triple
_:a
:name
"Alice"
is
created
and
used
as
curSubject
while
processing
the
annotation
production.
This section describes TriG-star, a minimal extension of the TriG format [ TRIG ] using the same production updates described in 3.2 Turtle-star .
RDF-star describes quoted triples , which are not necessarily present in any named graph , or within the default graph .
A TriG-star document defines an RDF-star dataset , composed of a single default graph and zero or more named graphs , all of which are RDF-star graphs .
TriG-star is defined to follow the same grammar as TriG, except for the EBNF productions specified below, which replace the productions having the same number (if any) in the original grammar.
The TriG-star grammar contains exactly the same production updates described in 3.2.1 Grammar with an additional change to the triplesOrGraph production.
| [3g] |
triplesOrGraph
|
::= |
labelOrSubject
(
wrappedGraph
|
predicateObjectList
'.'
)
|
| [8] |
objectList
|
::= |
object
annotation
?
(
','
object
annotation
?
)*
|
| [10] |
subject
|
::= |
iri
|
BlankNode
|
collection
|
quotedTriple
|
| [12] |
object
|
::= |
iri
|
BlankNode
|
collection
|
blankNodePropertyList
|
literal
|
quotedTriple
|
| [27t] |
quotedTriple
|
::= |
'<<'
qtSubject
verb
qtObject
'>>'
|
| [28t] |
qtSubject
|
::= |
iri
|
BlankNode
|
quotedTriple
|
| [29t] |
qtObject
|
::= |
iri
|
BlankNode
|
literal
|
quotedTriple
|
| [30t] |
annotation
|
::= |
'{|'
predicateObjectList
'|}'
|
The complete grammar may be found in C.2 TriG-Star EBNF Grammar .
TriG-star parsing uses the same updates described in 3.2.2 Parsing as applied to Section 5 of the TriG specification [ TRIG ].
As
with
Turtle-star,
the
quotedTriple
and
annotation
are
used
to
set
either
the
curSubject
or
curObject
,
and
do
not
directly
add
the
associated
quoted
triple
to
curGraph
.
Subsequent
productions
which
use
either
curSubject
or
curObject
may
result
in
adding
triples
to
curGraph
.
A conforming TriG-star parser MUST parse any valid TriG document and any valid Turtle-star document in addition to the Turtle-star grammar productions contained within a named graph .
This section is non-normative.
TriG-star allows the same expressivity as Turtle-star with the addition of allowing quoted triples and annotations within named graphs.
BASE <http://example.org/>
PREFIX : <#>
:G {
_:a :name "Alice" {| :statedBy :bob |} .
}
The
resulting
RDF-star
dataset
consists
of
an
empty
default
graph,
and
a
graph
named
http://example.org/#G
with
two
RDF-star
triples:
http://example.org/#name
,
"Alice"
),
where
b
is
a
blank
node
http://example.org/#name
,
"Alice"
),
http://example.org/#statedBy
,
http://example.org/#bob/
),
where
b
is
the
same
blank
node
This section describes N-Triples-star, a minimal extension of the N-Triples format [ N-TRIPLES ] allowing a subject or an object of an RDF-star triple to be a quoted triple .
N-Triples-star is defined to follow the same grammar as the N-Triples Grammar , except for the EBNF productions specified below, which replace the productions having the same number (if any) in the original grammar.
| [3] |
subject
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
quotedTriple
|
| [5] |
object
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
literal
|
quotedTriple
|
| [7t] |
quotedTriple
|
::= | "<<" subject predicate object ">>" |
The complete grammar may be found in C.3 N-Triples-Star EBNF Grammar .
The
changes
are
that
subject
and
object
productions
have
been
extended
to
accept
quoted
triples
,
which
are
described
by
the
new
production
7
.
In
contrast
to
[
N-TRIPLES
],
N-Triples-star
allows
recursion
on
the
subject
and
object
productions.
An
N-Triples-star
document
defines
an
RDF-star
graph
composed
of
a
set
of
RDF-star
triples
.
The
triple
production
produces
an
RDF-star
triple
composed
of
a
subject
,
predicate
,
and
object
.
In
addition
to
the
Term
Constructors
defined
in
[
N-TRIPLES
],
an
additional
constructor
is
defined
for
quotedTriple
of
type
RDF-star
triple
defined
by
the
terms
constructed
for
subject
,
predicate
,
and
object
.
All other productions MUST be handled as specified by Section 8.1 of the N-Triples specification [ N-TRIPLES ], while still applying the changes above recursively.
The [ N-QUADS ] format is extended to describe the N-Quads-star format using the same production updates described in the N-Triples-star Grammar .
The complete grammar may be found in C.4 N-Quads-Star EBNF Grammar .
As
RDF-star
describes
quoted
triples
and
not
quoted
quads,
the
graphLabel
component
of
an
N-Quads
statement
does
not
apply
to
the
quotedTriple
component.
An N-Quads-star document defines an RDF-star dataset , composed of a single default graph and zero or more named graphs , all of which are RDF-star graphs .
A
conforming
N-Quads-star
parser
MUST
parse
any
valid
N-Quads
document
and
additionally
parse
the
subject
and
object
productions
from
N-Triples-star
to
generate
RDF-star
triples
which
are
added
to
either
the
default
graph
or
associated
named
graph
,
as
appropriate.
This section is non-normative.
While this document specifies a small number of concrete syntaxes, nothing prevents other concrete syntaxes of RDF-star from being proposed. In particular, syntaxes such as RDF/XML [ RDF-SYNTAX-GRAMMAR ], and JSON-LD [ JSON-LD ], could be extended to support RDF-star.
This Section introduces SPARQL-star, which is an RDF-star-aware extension of the RDF query language SPARQL [ SPARQL11-QUERY ]; i.e., SPARQL-star can be used to query RDF-star graphs.
In the following, we introduce a number of SPARQL-star-specific definitions, which rely on the following notions, defined in SPARQL 1.1 Query Language [ SPARQL11-QUERY ]: query variable , triple pattern , property path pattern , property path expression , and solution mapping .
A SPARQL-star triple pattern is a 3-tuple that is defined recursively as follows:
As for RDF-star triples , a SPARQL-star triple pattern MUST NOT contain itself.
A SPARQL-star basic graph pattern ( BGP -star) is a set of SPARQL-star triple patterns .
A SPARQL-star property path pattern is a 3-tuple ( s , p , o ) where
A SPARQL-star solution mapping μ is a partial function from the set of all query variables to the set of all RDF-star terms . The domain of μ, denoted by dom(μ), is the set of query variables for which μ is defined.
The notion of a SPARQL-star solution mapping extends the notion of a standard SPARQL solution mapping ; that is, every SPARQL solution mapping is a SPARQL-star solution mapping . However, in contrast to SPARQL solution mappings , SPARQL-star solution mappings may map variables also to RDF-star triples .
All notions related to SPARQL solution mappings carry over naturally to SPARQL-star solution mappings. In particular, the definition of compatibility extends naturally to SPARQL-star solution mappings: two SPARQL-star solution mappings μ 1 and μ 2 are compatible if, for every variable v that is both in dom(μ 1 ) and in dom(μ 2 ), μ 1 (v) and μ 2 (v) are the same RDF-star term . In this case, μ 1 ∪ μ 2 is also a SPARQL-star solution mapping. Moreover, for any SPARQL-star solution mapping μ we write card[Ω](μ) to denote the cardinality of μ in a multiset Ω of such mappings. Finally, given a BGP -star B and a SPARQL-star solution mapping μ, we write μ( B ) to denote the result of replacing every variable v in B for which μ is defined with μ(v).
Next, we aim to carry over the notion of solutions for BGPs to BGP -star . To this end, we first define an auxiliary concept that carries over the notion of an RDF instance mapping [ RDF11-MT ] to RDF-star.
An RDF-star instance mapping σ is a partial function from the set of all blank nodes to the set of all RDF-star terms . The domain of σ, denoted by dom(σ), is the set of blank nodes for which σ is defined.
Similar to the corresponding notation for solution mappings, for an RDF-star instance mapping σ and a BGP -star B we write σ( B ) to denote the result of replacing every blank node b in B for which σ is defined with σ(b).
Now we are ready to define the notion of solution for BGP -star.
Given a BGP -star B and an RDF-star graph G , a SPARQL-star solution mapping μ is a solution for the BGP -star B over G if it has the following two properties
SPARQL-star is defined to follow the same grammar as SPARQL 1.1, except for the EBNF productions specified below, which replace the productions having the same number (if any) in the original grammar. The parts in which these productions differ from the corresponding productions in the original grammar are marked in bold font. Productions [174] and following have been added and have no counterpart in the original grammar.
The complete grammar may be found in C.5 SPARQL-Star EBNF Grammar .
This introduces a notation for quoted triple patterns (production [174] ), which is similar to the one defined for quoted triples in 3.2 Turtle-star , but accepting also variables . These quoted triple patterns are allowed in both the subject position ( [75] , [81] ) and the object position ( [80] , [87] ) of SPARQL-star triple patterns , as well as in the short-hand notation for querying collections ( [102] , [103] ).
Additionally, production [65] for values that can be used in the VALUES clause is extended to permit RDF-star triples as possible values, and the set of available built-in functions is extended with the five functions TRIPLE, SUBJECT, PREDICATE, OBJECT, and isTRIPLE ( [121] ) that are defined in 4.4 Function and Operator Definitions .
As defined for all keywords in SPARQL , the names of the five new built-in functions added by SPARQL-star are matched in a case-insensitive manner.
Yet another extension is that both the Object and the ObjectPath productions now accept an optional annotation pattern after each object. The purpose of this feature is to enable users to use the same kind of annotation syntax that is supported in Turtle-star. As in the case of Turtle-star, the annotation syntax in SPARQL-star is purely syntactic sugar that has to be processed in accordance to the first expansion rule in 4.3.2 Expand Syntax Forms .
A
restriction
to
the
use
of
the
annotation
syntax
in
SPARQL-star
exists
that
is
not
captured
by
the
grammar
as
defined
above:
An
AnnotationPatternPath
may
be
added
only
to
SPARQL-star
property
path
patterns
in
which
the
property
path
expression
is
a
PredicatePath
(i.e.,
a
single
IRI)
or
the
keyword
a
(as
a
short
form
for
the
IRI
rdf:type
).
Hence,
a
query
such
as
the
following
violates
this
restriction
and,
thus,
is
invalid
.
SELECT * WHERE {
?s :p/:q ?o {| ?pp ?oo |}.
}
While annotation patterns must not be added to property path patterns other than the ones permitted by the restriction above, it is possible to use property path expressions within annotation patterns (but without violating the restriction in the case of nested annotation patterns). For instance, the following query is valid.
SELECT * WHERE {
?s ?p ?o {| :p/:q ?oo |}.
}
Based
on
the
SPARQL
grammar,
the
SPARQL
specification
defines
the
process
of
converting
graph
patterns
and
solution
modifiers
in
a
SPARQL
query
string
into
a
SPARQL
algebra
expression
[
SPARQL11-QUERY,
Section 18.2
].
This
process
must
be
adjusted
to
consider
the
extended
grammar
introduced
above
.
In
the
following,
any
step
of
the
conversion
process
that
requires
adjustment
is
discussed.
As a basis of the translation, the SPARQL specification introduces a notion of in-scope variables . To cover the new syntax elements introduced in 4.2 Grammar this notion MUST be extended as follows.
The
translation
process
starts
with
expanding
abbreviations
for
IRIs
and
triple
patterns
[
SPARQL11-QUERY,
Section 18.2.2.1
].
This
step
MUST
be
extended
in
three
ways:
Annotation patterns MUST be replaced by additional SPARQL-star triple patterns that have the annotated triple pattern as a quoted triple pattern in their subject position.
Abbreviations for triple patterns with quoted triple patterns MUST be expanded as if each quoted triple pattern was a variable (or an RDF term ).
Abbreviations for IRIs in all quoted triple patterns MUST be expanded.
The translation of property path patterns has to be adjusted because the extended grammar allows for SPARQL-star property path patterns whose subject or object is a SPARQL-star triple pattern .
The translation as specified in the W3C specification distinguishes four cases. The first three of these cases do not require adjustment because they are taken care of either by recursion or by the adjusted translation of basic graph patterns (as defined in 4.3.4 Translate Basic Graph Patterns below). However, the fourth case MUST be adjusted as follows.
Let
X
P
Y
be
a
string
that
corresponds
to
the
fourth
case
in [
SPARQL11-QUERY,
Section 18.2.2.4
].
Given
the
grammar
introduced
in
4.2
Grammar
,
X
and
Y
may
be
an
RDF
term
,
a
variable
,
or
a
quoted
triple
pattern
,
respectively
(and
P
is
a
property
path
expression
).
The
string
X
P
Y
is
translated
to
the
algebra
expression
Path
(
X’
,
P
,
Y’
)
where
X’
and
Y’
are
the
result
of
calling
a
function
named
Lift
for
X
and
Y
,
respectively.
For
some
input
string
Z
(such
as
X
or
Y
)
that
can
be
an
RDF
term
,
a
variable
,
or
a
quoted
triple
pattern
,
the
function
Lift
is
defined
recursively
as
follows:
Lift
(
S
),
P
,
Lift
(
O
));
Lift
translates
every
quoted
triple
pattern
as
can
be
written
in
the
SPARQL-star
syntax
into
a
SPARQL-star
triple
pattern
.
After
translating
property
path
patterns
,
the
translation
process
collects
any
adjacent
triple
patterns
[...]
to
form
a
basic
graph
pattern
[
SPARQL11-QUERY,
Section 18.2.2.5
].
This
step
has
to
be
adjusted
because
triple
patterns
in
the
extended
syntax
may
have
a
quoted
triple
pattern
in
their
subject
position
or
in
their
object
position
(or
in
both).
To
ensure
that
every
result
of
this
step
is
a
BGP
-star
,
before
adding
a
triple
pattern
to
its
corresponding
collection,
its
subject
and
object
MUST
be
replaced
by
the
result
of
calling
function
Lift
for
the
subject
and
the
object,
respectively.
SPARQL
introduces
operators
and
functions
that
can
be
used
in
an
expression
of
a
FILTER
clause,
a
BIND
clause,
or
a
SELECT
clause
(see
Section 17.3
and
Section 17.4
in
[
SPARQL11-QUERY
]).
While
these
operators
and
functions
are
defined
to
operate
on
RDF
terms
and
query
variables
,
for
SPARQL-star
they
have
to
be
defined
to
operate
on
RDF-star
terms
and
query
variables
.
To
this
end,
when
using
these
operators
and
functions
in
the
context
of
SPARQL-star,
their
definitions
as
given
in
Section 17.4
of
[
SPARQL11-QUERY
]
are
extended
by
assuming
that
any
mention
of
RDF
term
as
a
data
type
for
operands
is
understood
to
be
the
type
of
all
RDF-star
terms
.
SPARQL-star
introduces
five
new
functions
that
are
defined
as
follows
(where
the
data
types
RDF-star
term
and
RDF-star
triple
capture
all
RDF-star
terms
and
all
RDF-star
triples
,
respectively).
The modifications to functions and operators for triple terms are:
sameTerm
function
(SPARQL
1.1
Section
17.4.1.8
)
sparql-compare
for
the
=
operator
and
other
comparison
mappings
RDFterm-equal
(SPARQL
1.1
Section
17.4.1.7
)
=
and
other
operators
(SPARQL
1.1
Section
17.3
)
ORDER
BY
(SPARQL
1.1
Section
15.1
)
RDF-star
triple
TRIPLE
(
RDF-star
term
term1
,
RDF-star
term
term2
,
RDF-star
term
term3
)
If
the
3-tuple
(
term1
,
term2
,
term3
)
is
an
RDF-star
triple
,
the
function
returns
this
triple.
If
the
3-tuple
is
not
an
RDF-star
triple,
then
the
function
raises
an
error.
RDF-star
term
SUBJECT
(
RDF-star
triple
triple
)
If
triple
is
an
RDF-star
triple
,
the
function
returns
the
subject
of
this
triple.
Passing
anything
other
than
an
RDF-star
triple
is
an
error.
RDF-star
term
PREDICATE
(
RDF-star
triple
triple
)
If
triple
is
an
RDF-star
triple
,
the
function
returns
the
predicate
of
this
triple.
Passing
anything
other
than
an
RDF-star
triple
is
an
error.
RDF-star
term
OBJECT
(
RDF-star
triple
triple
)
If
triple
is
an
RDF-star
triple
,
the
function
returns
the
object
of
this
triple.
Passing
anything
other
than
an
RDF-star
triple
is
an
error.
xsd:boolean
isTRIPLE
(
RDF-star
term
term
)
Returns
true
if
term
is
an
RDF-star
triple
.
Returns
false
otherwise.
RDF-star
triple
<<
RDF-star
term
term1
,
RDF-star
term
term2
,
RDF-star
term
term3
>>
A
Quoted
Triple
Expression
<<S
P
O>>
,
where
S
,
P
and
O
conform
to
ExprVarOrTerm
,
is
evaluated
as
TRIPLE(S,
P,
O)
.
xsd:boolean
sameTerm
(
term
,
term
)
The
function
sameTerm
is
extended
to
support
term
comparison
for
RDF-star
triple
terms
by
defining:
Extended
Definition:
sameTerm
If both arguments are RDF-star triple terms:
sameTerm
(<<S1
P1
O1>>,
<<S2
P2
O2>>)
is evaluated as
sameTerm(S1,
S2)
&&
sameTerm(P1,
P2)
&&
sameTerm(O1,
O2)
This is applied recursively.
If
one
argument
is
an
RDF-star
triple
term
and
the
other
argument
is
not,
the
result
is
false
.
The
function
sparql-compare
is
defined
to
support
value-comparison
operators
such
as
=
and
ORDER
BY
.
xsd:boolean
sparql-compare
(
RDF-star
term
,
RDF-star
term
)
The
function
sparql-compare
returns
-1
,
0
,
1
,
or
throws
an
error,
based
on
the
comparison
of
two
RDF-star
terms
.
When
comparing
two
RDF-star
triple
terms,
comparison
is
by
pairwise
comparison
of
subject,
then
predicate,
then
object.
Definition:
sparql-compare
<
,
=
,
>
)
and
return
the
comparison
value
(
-1
,
0
,
+1
)
or
throw
an
error
as
defined
by
SPARQL
1.1.
sparql-compare(SUBJECT(A),
SUBJECT(B))
!=
0
,
then
return
this
value.
sparql-compare(PREDICATE(A),
PREDICATE(B))
!=
0
,
then
return
this
value.
sparql-compare(OBJECT(A),
OBJECT(B))
The
function
RDFterm-equal
is
the
default
dispatch
for
the
=
operator.
This
is
extended
to
cover
RDF-star
terms
so
that
it
returns
true
if
term1
and
term2
are
both
RDF-star
triple
terms
and
RDFterm-equal
is
true
for
pairwise
comparison
of
the
component
RDF
terms.
Extended
Definition:
RDFTerm-equal
If
exactly
one
of
the
arguments
is
an
RDF-star
triple
term,
return
false
.
If both arguments are RDF-star triple terms:
RDFterm-equal
(<<S1
P1
O1>>,
<<S2
P2
O2>>)
is evaluated as
RDFterm-equal(S1,
S2)
&&
RDFterm-equal(P1,
P2)
&&
RDFterm-equal(O1,
O2)
It
produces
an
error
if
matching
RDF
terms
in
nested
RDF
triple
terms
when
both
are
literals
but
not
the
same
RDF
term.
This
is
the
same
as
the
existing
RDFterm-equal
.
Operator
mapping
overrides
this
behavior.
The case of two RDF-star triple terms is covered by the operator dispatch mappings and covers cases involving literals.
New operator mappings are added for RDF-star triple terms for section SPARQL 1.1 Query 17.3 Operator Mapping
| Operator | Type(A) | Type(B) | Evaluation | Result type |
|---|---|---|---|---|
| SPARQL-star Tests | ||||
| A = B | RDF triple term | RDF triple term | op:numeric-equal ( sparql-compare (A, B), 0) | xsd:boolean |
| A != B | RDF triple term | RDF triple term | fn:not ( op:numeric-equal ( sparql-compare (A, B), 0)) | xsd:boolean |
| A < B | RDF triple term | RDF triple term | op:numeric-equal ( sparql-compare (A, B), -1) | xsd:boolean |
| A <= B | RDF triple term | RDF triple term | fn:not ( op:numeric-equal ( sparql-compare (A, B), 1)) | xsd:boolean |
| A > B | RDF triple term | RDF triple term | op:numeric-equal ( sparql-compare (A, B), 1) | xsd:boolean |
| A >= B | RDF triple term | RDF triple term | fn:not ( op:numeric-equal ( sparql-compare (A, B), -1)) | xsd:boolean |
There is an added item to the ordering of terms when they would not otherwise be ordered. RDF-star triple terms are placed last (highest).
RDF-star
triple
terms
are
compared
using
the
<
operator.
While
SPARQL-star
does
not
define
a
total
ordering
of
all
possible
RDF-star
terms,
implementations
should
provide
some
ordering
for
ORDER
BY
that
does
not
change
between
queries
if
the
data
has
not
changed.
This section is non-normative.
By the evaluation semantics of SPARQL-star as defined in 4.6 Evaluation Semantics , the five new built-in functions defined above can be used in exactly the same manner as the functions defined in the SPARQL 1.1 spec . For instance, the following SPARQL-star query retrieves every asserted triple that is both contained in the default graph of the queried RDF-star dataset and has a quoted triple as its subject .
SELECT ?t WHERE {
?s ?p ?o .
BIND( TRIPLE(?s,?p,?o) AS ?t )
FILTER( isTRIPLE(SUBJECT(?t)) )
}
Instead
of
accessing
the
subject
of
the
triples
in
the
FILTER
after
the
BIND
clause,
as
was
done
in
the
previous
query,
a
semantically
equivalent
query
may
apply
the
FILTER
directly
on
the
variable
?s
,
as
follows:
SELECT ?t WHERE {
?s ?p ?o .
BIND( TRIPLE(?s,?p,?o) AS ?t )
FILTER( isTRIPLE(?s) )
}
While
the
triples
that
the
previous
example
queries
bind
to
variable
?t
occur
in
the
queried
data,
the
TRIPLE
function
can
be
used
to
construct
triples
that
may
not
be
in
the
data.
For
instance,
the
following
query
uses
the
subject
of
each
asserted
triple
in
the
default
graph
of
the
queried
RDF-star
dataset
to
construct
another
triple,
and
bind
it
to
the
variable
?t
.
Notice
that
the
result
of
this
query
contains
as
many
SPARQL-star
solution
mappings
as
there
are
asserted
triples
in
the
queried
graph,
and
there
may
be
duplicates
in
the
result
if
multiple
asserted
triples
have
the
same
subject.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?t WHERE {
?s ?p ?o .
BIND( TRIPLE(?s,rdf:type,rdfs:Resource) AS ?t )
}
There are cases where the effects of using the new TRIPLE function are not immediately obvious just from its definition, particularly when considering the interplay of this function with the BNODE function when used within GRAPH clauses . Some of these cases are discussed below.
Consider the following SPARQL-star query.
SELECT ( COUNT(?t1) AS ?t1Count )
( COUNT(?t2) AS ?t2Count )
( COUNT(?t3) AS ?t3Count )
( COUNT(DISTINCT ?t1) AS ?t1DistCount )
( COUNT(DISTINCT ?t2) AS ?t2DistCount )
( COUNT(DISTINCT ?t3) AS ?t3DistCount )
WHERE {
GRAPH ?g {
BIND( TRIPLE(BNODE(), :p, :o) AS ?t1 )
BIND( TRIPLE(BNODE("id"), :p, :o) AS ?t2 )
BIND( TRIPLE(:s, :p, :o) AS ?t3 )
}
}
When
evaluated
over
an
RDF-star
dataset
that
contains
n
named
graphs
,
where
n
>0,
the
GRAPH
clause
results
in
one
SPARQL-star
solution
mapping
per
named
graph.
The
SELECT
clause
collapses
these
n
mappings
into
a
single
mapping
that
is
defined
for
the
six
variables
introduced
in
the
SELECT
clause.
(If
n
=0,
the
query
result
is
the
empty
set.)
Each
of
these
six
variables
is
mapped
to
an
integer-typed
literal
with
values
as
follows.
For
each
of
?t1Count
,
?t2Count
,
and
?t3Count
,
the
value
is
n
,
because
the
variables
?t1
,
?t2
,
and
?t3
are
bound
in
each
of
the
n
solution
mappings
produced
for
the
GRAPH
clause.
For
the
variable
?t1DistCount
,
the
value
is
also
n
,
because
the
BIND
clauses
are
evaluated
n
times
(once
for
each
named
graph)
and
the
subexpression
BNODE()
always
creates
a
different
new
blank
node;
thus,
the
triples
created
for
variable
?t1
are
all
different
from
one
another.
This
is
also
the
case
if
the
BNODE
function
is
used
with
an
argument;
i.e.,
the
value
of
?t2DistCount
is
n
too.
In
contrast,
the
variable
?t3
is
mapped
to
the
same
triple
within
each
evaluation
of
the
third
BIND
clause;
thus,
the
value
for
?t3DistCount
is 1.
Notice that the BNODE function has to be used to create a blank node; simply writing a blank node directly in an expression is not permitted .
Notice as well that the preceding query is special in two ways: its GRAPH clause does not actually consider the content of the named graphs; and the expressions in the BIND clauses do not contain variables. In contrast, the GRAPH clause and the BIND clauses in the following query do.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdfg: <http://www.w3.org/2004/03/trix/rdfg-1/>
SELECT ( COUNT(?t1) AS ?t1Count )
( COUNT(?t2) AS ?t2Count )
WHERE {
GRAPH ?g {
?g rdf:type rdfg:Graph .
BIND( TRIPLE(?g, rdf:type, rdfs:Resource) AS ?t1 )
BIND( TRIPLE(?x, rdf:type, rdfs:Resource) AS ?t2 )
}
}
For
every
RDF-star
dataset
with
n
>0
named
graphs,
the
result
of
this
query
consists
of
a
single
SPARQL-star
solution
mapping
that
is
defined
for
the
three
variables
introduced
in
the
SELECT
clause.
The
value
of
?t1Count
is
the
number
of
named
graphs
in
the
queried
dataset
that
contain
a
triple
of
the
form
(
u
,
rdf:type
,
rdfg:Graph
)
such
that
u
is
the
name
of
the
named
graph
in
the
dataset.
The
value
of
?t2Count
is
always 0 (zero),
because
evaluating
the
expression
of
the
second
BIND
clause
results
in
an
error,
because
the
variable
?x
is
not
bound
in
the
scope
of
this
evaluation.
As
a
side
note,
evaluating
the
expression
of
the
first
BIND
clause
would
also
result
in
an
error,
if
the
variable
?g
was
not
mentioned
inside
the
GRAPH
clause
(e.g.,
if
the
given
triple
pattern
was
not
there).
The
SPARQL
specification
defines
a
function
eval(
D
(
G
), algebra expression)
as
the
evaluation
of
an
algebra
expression
with
respect
to
a
dataset
D
having
active
graph
G
[
SPARQL11-QUERY,
Section
18.6
].
Recall
that
the
dataset
D
in
the
context
of
SPARQL-star
is
an
RDF-star
dataset
and,
thus,
the
active
graph
G
is
an
RDF-star
graph
,
and
so
is
any
other
graph
in
dataset
D
.
The
definition
of
the
eval
function
is
recursive;
the
base
case
of
this
definition
for
SPARQL-star
are
given
as
follows:
For any other algebra expression, the SPARQL specification defines algebra operators [ SPARQL11-QUERY ]. These definitions can be extended naturally to operate over multisets of SPARQL-star solution mappings (instead of ordinary solution mappings ). Given this extension, the recursive steps of the definition of the eval function for SPARQL-star are the same as in the SPARQL specification.
In SPARQL, queries can take four forms: SELECT , CONSTRUCT , DESCRIBE , and ASK - see SPARQL1.1 Query, Section 16 [ SPARQL11-QUERY ]. The first of these returns a sequence of solution mappings that contain variable bindings. The second and third both return an RDF graph, and the last returns a boolean value.
The result of the ASK query form is not changed by the introduction of RDF-star, and the result of the CONSTRUCT and DESCRIBE forms can be represented by Turtle-star . However, since the SELECT form deals with returning individual RDF terms, the specific serialization formats for representing such query results need to be extended so that the new quoted triple RDF term can be represented. In this section, we propose extensions for the two most common formats for this purpose: SPARQL 1.1 Query Results JSON Format , and SPARQL Query Results XML Format (Second Edition) .
The result of a SPARQL SELECT query is serialized in JSON as defined in SPARQL 1.1 Query Results JSON Format , which specifies a JSON representation of variable bindings to RDF terms (see [ sparql11-results-json, Section 3.2 ]). To accommodate the new RDF term for quoted triples that RDF-star introduces, the table of RDF term JSON representations in sparql11-results-json, Section 3.2.2 is extended with the following entry:
S
,
predicate
RDF
term
P
and
object
RDF
term
O
{
"type": "triple",
"value": {
"subject": S,
"predicate": P,
"object": O
}
}
where
S
,
P
and
O
are
encoded
using
the
same
format,
recursively.
The result of a SPARQL SELECT query is serialized in XML as defined in SPARQL Query Results XML Format (Second Edition) . This format proposes an XML representation of variable bindings to RDF terms.
To accommodate the new RDF term for quoted triples that RDF-star introduces, the list of RDF terms and their XML representations in [ RDF-SPARQL-XMLRES Section 2.3.1 ] is extended as follows:
S
,
predicate
term
P
,
and
object
term
O
<binding>
<triple>
<subject>S</subject>
<predicate>P</predicate>
<object>O</object>
</triple>
</
binding
>
where
S
,
P
and
O
are
encoded
recursively,
using
the
same
format,
without
the
enclosing
<binding>
tag.
This section specifies SPARQL-star Update, an update language for RDF-star. This language extends SPARQL Update [ SPARQL11-UPDATE ], the update language for RDF, by adding RDF-star-specific features and semantics.
This section is non-normative.
While SPARQL Update operates over a graph store that consists of RDF graphs, SPARQL-star Update extends the notion of graph store to contain RDF-star graphs instead of RDF graphs. That is, a graph store in the context of SPARQL-star Update contains one (unnamed) slot holding an RDF-star graph, referred to as the default graph, and zero or more named slots holding other RDF-star graphs, referred to as named graphs. Then, all graph management operations in SPARQL Update ( CREATE , DROP , COPY , MOVE , ADD ) carry over directly to SPARQL-star Update with the only difference being that in SPARQL-star Update these operations manage RDF-star graphs. For instance, the CREATE operation in SPARQL-star Update creates an RDF-star graph rather than a pure RDF graph. Similarly, the graph update operations LOAD and CLEAR in SPARQL-star Update operate with RDF-star graphs in the same way as their SPARQL Update counterparts operate with RDF graphs.
The only operations that SPARQL-star Update actually extends are the graph update operations INSERT DATA , DELETE DATA , and DELETE/INSERT . This section describes these extensions informally. While this description focuses mainly on updates to the default graph, the operations can also be applied to the named graphs.
The INSERT DATA operation can be used to add a given set of triples into the graph store. In the context of SPARQL-star Update, these triples may be RDF-star triples . As an example, consider the following INSERT DATA operation.
PREFIX : <http://www.example.org/>
INSERT DATA {
:alice :claims << :bob :age 23 >> .
}
Suppose
this
INSERT
DATA
operation
is
executed
over
a
graph
store
with
an
empty
default
graph.
After
executing
this
operation,
the
default
graph
contains
the
given
(nested)
RDF-star
triple.
Now,
it
is
possible
to
query
for
this
triple.
For
instance,
the
following
SPARQL-star
query
returns
a
single
solution
mapping
in
which
the
variables
?p
and
?a
are
mapped
to
the
IRI
:alice
and
the
literal
23
,
respectively.
PREFIX : <http://www.example.org/>
SELECT ?p ?a WHERE {
?p :claims << :bob :age ?a >> .
}
Notice
that
inserting
a
nested
triple
does
not
automatically
also
insert
its
quoted
triple(s)
as
asserted
triple(s)
into
the
graph.
Hence,
in
the
previous
example,
after
executing
the
given
INSERT
DATA
operation,
the
default
graph
does
not
contain
the
triple
:bob
:age
23
.
In
other
words,
a
query
such
as
the
following
would
have
an
empty
result.
PREFIX : <http://www.example.org/>
SELECT ?a WHERE {
:bob :age ?a .
}
For
a
quoted
triple
to
be
present
in
the
graph
as
an
asserted
triple
,
it
needs
to
be
inserted
as
such.
For
instance,
the
INSERT
DATA
operation
in
the
example
above
may
be
modified
as
follows
in
order
to
insert
not
only
the
nested
triple
but
also
the
triple
:bob
:age
23
.
PREFIX : <http://www.example.org/>
INSERT DATA {
:bob :age 23 .
:alice :claims << :bob :age 23 >> .
}
The DELETE DATA operation can be used to remove a given set of triples from the graph store. In the context of SPARQL-star Update, this may include removing nested RDF-star triples as demonstrated in the following example.
PREFIX : <http://www.example.org/>
DELETE DATA {
:alice :claims << :bob :age 23 >> .
}
After executing this DELETE DATA operation over a graph store with a default graph that contains the given nested triple, the graph will not contain this triple any longer. If the graph did not contain that nested triple in the first place, the graph will remain unchanged by the given DELETE DATA operation.
Notice
that
deleting
triples
by
using
the
DELETE
DATA
operation
does
not
affect
any
other
triples
in
the
corresponding
graphs.
For
instance,
for
a
default
graph
that
contains
the
triple
:bob
:age
23
as
an
asserted
triple
,
the
DELETE
DATA
operation
given
above
does
not
delete
this
asserted
triple
.
In
contrast,
the
following
operation
would
delete
this
asserted
triple
but
it
would
not
delete
any
nested
triple
that
contains
the
given
triple
as
a
quoted
triple
.
PREFIX : <http://www.example.org/>
DELETE DATA {
:bob :age 23 .
}
The
DELETE/INSERT
operation
can
be
used
to
remove
or
add
triples
based
on
variable
bindings
obtained
by
evaluating
a
given
WHERE
clause.
As
an
example,
the
following
DELETE/INSERT
operation
replaces
all
nested
triples
in
which
:alice
is
the
subject
by
nested
triples
in
which
:carol
is
the
subject.
PREFIX : <http://www.example.org/>
DELETE { :alice ?pp <<?s ?p ?o>> . }
INSERT { :carol ?pp <<?s ?p ?o>> . }
WHERE
{
:alice
?pp
<<?s
?p
?o>>
.
}
As in SPARQL Update, in SPARQL-star Update it is possible to use variations of the DELETE/INSERT operations in which either the DELETE clause or the INSERT clause are omitted.
When removing triples via the DELETE clause (irrespective of whether the INSERT clause is omitted or not), the effects with respect to nested triples must be the same as described above for the DELETE DATA operation; i.e., only the triples that are explicitly identified to be deleted are deleted. Similarly, inserting triples via the INSERT clause has the same effects as described above for the INSERT DATA operation; i.e., inserting nested triples does not automatically also insert their quoted triples as asserted triples into the graph. Of course, it is possible to request such inserts explicitly as demonstrated in the following example.
PREFIX : <http://www.example.org/>
DELETE { :alice ?pp <<?s ?p ?o>> . }
INSERT { :carol ?pp <<?s ?p ?o>> . ?s ?p ?o .}
WHERE
{
:alice
?pp
<<?s
?p
?o>>
.
}
While
all
SPARQL-star
Update
examples
above
focus
only
on
the
default
graph
of
a
graph
store,
SPARQL-star
Update
can
also
be
used
to
update
the
named
graphs
of
a
graph
store,
which
works
in
exactly
the
same
way
as
in
SPARQL
Update.
As
a
possible
example
consider
the
following
INSERT
operation
which
retrieves
all
quoted
triples
found
in
nested
triples
in
the
default
graph
and
inserts
them
as
asserted
triples
into
the
named
graph
with
IRI
:graph2
.
PREFIX : <http://www.example.org/>
INSERT {
GRAPH :graph2 { ?s ?p ?o }
}
WHERE {
{ <<?s ?p ?o>> ?pp ?oo }
UNION
{ ?ss ?pp <<?s ?p ?o>> }
}
SPARQL-star Update is an extension of the SPARQL Update language [ SPARQL11-UPDATE ]. As mentioned in SPARQL 1.1 Update, Appendix C [ SPARQL11-UPDATE ], the grammar of the latter is provided as part of the SPARQL 1.1 Query grammar . Similarly, the grammar of SPARQL-star Update is provided as part of the grammar of the SPARQL-star query language, which is defined by the SPARQL 1.1 Query grammar with the extensions specified in 4.2 Grammar . As a result of these extensions, the production rules QuadData and QuadPattern , which are used in the definition of SPARQL Update [ SPARQL11-UPDATE ], are extended to capture nested triples and nested triple patterns as demonstrated in the examples above.
The semantics of SPARQL-star Update operations can also be defined by a simple extension of the formalization of SPARQL Update [ SPARQL11-UPDATE ]. This extension assumes that any mention of "RDF triple" or "triple" in the formalization of SPARQL Update is understood as an RDF-star triple . Similarly, "RDF graph" and "solution mapping" are understood as RDF-star graph and SPARQL-star solution mapping , respectively. Any mention of the "evaluation function eval()" is understood as the eval function for SPARQL-star as defined in 4.6 Evaluation Semantics .
In this section, we provide a model-theoretic semantics for RDF-star, based on the one defined in RDF 1.1 Semantics [ RDF11-MT ]. More precisely, we define a mapping from RDF-star's abstract syntax into standard RDF's abstract syntax, and define the semantics of RDF-star graphs in terms of the semantics of the mapped RDF graphs .
In
the
following,
we
will
use
abbreviated
IRIs
using
the
prefix
unstar:
which
is
an
alias
for
the
namespace
https://w3c.github.io/rdf-star/unstar#
.
We also introduce a number of definitions specific to RDF-star, which rely on the following notions, defined in RDF 1.1 Concepts and Abstract Syntax [ RDF11-CONCEPTS ] and RDF 1.1 Semantics [ RDF11-MT ]: datatype , lexical form , ill-typed , merging , satisfiability , unsatisfiability , entailment , and equivalence .
We define a mapping L that maps any IRI or literal t to a literal with:
xsd:string
as
its
datatype
,
and
xsd:string
datatype
,
the
representation
MUST
simply
match
the
STRING_LITERAL_QUOTE
production
(i.e.,
without
an
explicit
datatype
IRI
).
Given an RDF-star graph G , the following steps define the unstar mapping , which transform G into an RDF graph that we call unstar ( G ).
https://w3c.github.io/rdf-star/unstar#
:
unstar:subject
,
s
)
unstar:predicate
,
p
)
unstar:object
,
o
)
unless
o
is
an
ill-typed
literal
unstar:subjectLexical
,
L
(
s
))
unless
s
is
a
blank
node
unstar:predicateLexical
,
L
(
p
))
unstar:objectLexical
,
L
(
o
))
unless
o
is
a
blank
node
After
these
steps,
unstar
(
G
)
is
an
RDF
graph
,
as
it
contains
no
quoted
triples
.
Note
that
if
G
contains
no
quoted
triple
and
no
IRI
in
the
unstar:
namespace,
then
unstar
(
G
) =
G
.
Following RDF 1.1 Semantics , we define the notions of satisfiability and entailment for RDF-star graphs . Given two RDF-star graphs G and H :
It
is
easy
to
see
that,
in
the
special
case
of
RDF
graphs
G
and
H
(i.e.
RDF-star
graphs
containing
no
quoted
triple
),
G
is
star-
satisfiable
if
and
only
if
G
is
simply
satisfiable
,
and
G
star-
entails
H
if
and
only
if
G
simply
entails
H
.
This
is
trivially
true
if
G
and
H
do
not
contain
any
unstar:
IRI
(in
which
case
they
are
left
unchanged
by
the
unstar
mapping
).
But
this
is
also
true
if
they
do
contain
such
IRIs
(as
the
renaming
performed
by
the
unstar
mapping
has
no
significant
impact
on
the
semantic
relationships
between
the
two
graphs).
Star-
entailment
can
therefore
be
considered
as
a
natural
extension
of
simple
entailment
to
RDF-star
graphs
.
Other notions of satisfiability and entailment , such as RDF entailment or RDFS entailment , can be extended in the same way for RDF-star graphs .
RDF 1.1 Semantics [ RDF11-MT ] defines the merging of two or more RDF graphs as "[taking their] union after forcing any shared blank nodes, which occur in more than one graph, to be distinct in each graph." Note that, in the case of RDF-star graphs , any blank node in the constituent terms of that graph is governed by the definition above, not only those in the subject or object position of some asserted triple .
#### graph #1 :alice :says << _:x :name "bob" >>, << _:x :likes :alice >>. #### graph #2 :bob :says << :alice :hates _:x >>. #### Merge of graphs #1 and #2 → :alice :says << _:y :name "bob" >>, << _:y :likes :alice >>. :bob :says << :alice :hates _:z >>.
This section is non-normative.
It is important to notice that the definitions given above for satisfiability and entailment of RDF-star graphs do not mandate that implementations actually transform RDF-star graphs using the unstar mapping defined above. It should be possible to implement the semantics by directly handling RDF-star's abstract syntax .
Care must be taken when implementations that rely on the unstar mapping combine the resulting RDF graphs through union or merge . Given two RDF-star graphs G and H , it may be the case that unstar ( G ∪ H ) ≠ unstar ( G ) ∪ unstar ( H ).
In particular, if G and H contain the same quoted triple , this triple will be mapped to a single blank node in unstar ( G ∪ H ), but in two potentially different blank nodes in unstar ( G ) ∪ unstar ( H ). These blank nodes will need to be unified in order to reconstruct unstar ( G ∪ H ).
Conversely, nothing in the definition of the unstar mapping prevents it from generating the same blank node b for a quoted triple of G , and for a different quoted triple of H (provided that b is not present in either G nor H ). In that case, not only would unstar ( G ) ∪ unstar ( H ) be different from unstar ( G ∪ H ), but it would lose some information by mixing the descriptions of the two quoted triples .
Since the unstar mapping transforms any RDF-star graph into a standard ("non-star") RDF graph , it might be tempting to use this mapping for conveying RDF-star graphs to legacy RDF systems. However, this has a number of caveats.
First,
the
unstar
mapping
alters
the
semantics
of
the
graph:
in
general,
a
graph
G
is
not
equivalent
to
its
"unstarred"
version
unstar
(
G
),
even
if
G
is
a
standard
RDF
graph
containing
no
quoted
triples
.
(More
precisely,
they
are
equivalent
only
if
G
contains
no
quoted
triples
and
no
IRIs
from
the
unstar:
namespace.)
Second,
when
a
legacy
RDF
system
communicates
an
RDF
graph
to
an
RDF-star-aware
system,
there
is
no
means
by
which
the
latter
can
determine
with
certainty
whether
the
graph
is
the
result
of
applying
the
unstar
mapping
,
and
thus
needs
to
be
transformed
back.
(The
presence
of
unstar:
IRIs
in
the
graph
can
be
used
as
a
hint,
but
such
IRIs
can
also
be
used
independently
of
the
mapping.)
Additional
metadata
should
therefore
be
attached
to
unstarred
graphs,
so
that
RDF-star
systems
know
whether
or
not
they
need
to
apply
the
inverse
transformation
of
unstar
.
Finally, legacy RDF systems may alter unstarred graphs in ways that prevent their transformation back to the original RDF-star graph . For example, it has been pointed out above how combining several unstarred graphs may not yield the expected result. Another example is the removal of some arcs, such that a quoted triple is not completely described anymore, and can not be reconstructed.
The
way
the
unstar
mapping
is
defined,
the
denotation
of
a
quoted
triple
does
not
only
depend
on
the
denotation
of
its
component
terms,
but
also
on
their
syntactical
form
(for
IRIs
and
literals).
This
behavior
is
referred
to
as
referential
opacity
.
A
consequence
is
that
two
different
triples,
that
would
be
semantically
equivalent
if
asserted,
are
not
automatically
considered
to
denote
the
same
thing
when
quoted
.
In
the
example
below,
assuming
D-entailment
:
while
"104232"^^xsd:nonNegativeInteger
and
"000104232"^^xsd:nonNegativeInteger
denote
the
same
thing
(namely,
the
number
104232),
the
two
quoted
triples
are
allowed
to
have
different
denotations,
and
so
the
entailment
does
not
hold.
#### under D-entailment
<< dbr:Linköping dbo:populationTotal "104232"^^xsd::nonNegativeInteger >>
:source <https://dbpedia.org/data/Linköping>.
#### does NOT entail
<< dbr:Linköping dbo:populationTotal "000104232"^^xsd::nonNegativeInteger >>
:source <https://dbpedia.org/data/Linköping>.
#
(notice
the
leading
zeros
in
the
literal)
Similarly,
in
the
example
below
and
under
OWL
entailment
[
OWL2-Overview
],
while
:superman
and
:clark
are
inferred
to
denote
one
and
the
same
person
(because
of
the
owl:sameAs
relationship
between
them),
the
two
quoted
triples
are
not
automatically
considered
to
denote
the
same
thing.
#### under OWL-entailment :superman owl:sameAs :clark. << :superman :can :fly >> :reportedBy :clark. #### does NOT entail << :clark :can :fly >> :reportedBy :clark.
Note that this may lead to counter-intuitive results when the annotation syntax is used, as illustrated in the example below.
#### under D-entailment
dbr:Linköping dbo:populationTotal "104232"^^xsd::nonNegativeInteger
{| :source <https://dbpedia.org/data/Linköping> |}.
#### does NOT entail
dbr:Linköping dbo:populationTotal "000104232"^^xsd::nonNegativeInteger
{| :source <https://dbpedia.org/data/Linköping> |}.
# (notice the leading zeros in the literal)
#### more precisely, it DOES entail
dbr:Linköping dbo:populationTotal "000104232"^^xsd::nonNegativeInteger.
#### but it does NOT entail
<< dbr:Linköping dbo:populationTotal "000104232"^^xsd::nonNegativeInteger >>
:source
<https://dbpedia.org/data/Linköping>.
Referencial opacity is well suited for use-cases where the syntactical form of the annotated statements may be significant (like annotating statements from other graphs or annotating commit deltas ). On the other hand, other use-cases would expect some degree of referential transparency. Consider the case of attributed/evidenced triples . The annotation is understood to be about the fact asserted by the triple rather than the triple itself. In this use case, one might then expect more inferences than provided by the base semantics. Consider the following example.
<< dbr:Linköping dbo:populationTotal "104232"^^xsd::nonNegativeInteger >> :measuredOn "2010-12-31"^^xsd:date ; :source <https://dbpedia.org/data/Linköping.ttl> . ### Candidate entailment #1 << dbr:Linköping dbo:populationTotal "000104232"^^xsd::nonNegativeInteger >> :measuredOn "2010-12-31"^^xsd:date . ### Candidate entailment #2 << dbr:Linköping dbo:populationTotal "000104232"^^xsd::nonNegativeInteger >> :source <https://dbpedia.org/data/Linköping.ttl> . # (notice the leading zeros in the literal in both candidate entailments)
One
could
argue
that
the
candidate
entailment
#1
is
desirable
because
the
property
:measuredOn
is
understood
to
be
about
the
statement
made
by
the
subject
triple
(that
statement
was
true
on
the
given
date,
regardless
of
its
RDF
expression,
in
this
case
using
an
object
value
equivalent
to
104232
).
On
the
other
hand,
the
candidate
entailment
#2
may
be
considered
not
desirable
because
the
predicate
:source
is
about
the
triple
itself
(that
specific
triple
was
parsed
from
the
given
Turtle
file).
In
Section
7.
RDF-star
vocabulary
,
we
introduce
the
notion
of
transparency-enabling
property
(TEP)
,
for
selectively
enabling
this
kind
of
entailment
on
specific
properties.
The
basis
of
the
idea
is
that
each
such
property
p
is
identified
by
adding
to
the
RDF-star
graph
a
triple
of
the
form
(
p
,
rdf:type
,
rdf-star:TransparencyEnablingProperty
);
i.e.,
for
the
previous
example,
this
triple
would
be
(
:measuredOn
,
rdf:type
,
rdf-star:TransparencyEnablingProperty
).
This
would
make
candidate
entailment
#1
above
valid.
The
semantics
of
such
TEPs
is
formally
defined
in
Section
7.3
Vocabulary
semantics
.
Notice that enabling referential transparency based on such TEPs is only local to the RDF-star graph(s) in which the property is stated to be a TEP (or where this statement can be inferred as per the entailment regime considered). In other words, for every graph G in which a property is not stated to be transparency enabling, all quoted triples appearing in G as subject or object of that property are stilled considered as referentially opaque, even if there may exist some other graph in which the property is stated to be transparency enabling.
This proposal for TEPs makes no distinction regarding the position (subject or object) of the quoted triples . The group did consider a finer-grained alternative, where selective transparency could also be enabled only for the subjects (resp. objects) of the TEP. This was however ruled out as overly complex for a limited added value.
Given the potential drawbacks of the referential opacity provided by the current semantics, as described in the beginning of Section 6.4.5 Selective referential transparency above, the group has considered other alternative semantics. No clear consensus was reached, however, to decide whether these alternatives should be used as a replacement, or as a semantic extension , of the current semantics.
A fully referentially transparent semantics can be achieved by changing the step 2.4 of the unstar mapping algorithm as follows:
unstar:subject
,
s
)
unstar:predicate
,
p
)
unstar:object
,
o
)
In the examples above ( Example 36 , Example 37 , Example 38 , Example 39 ), all the entailments would now hold automatically. This could be a problem in some use-cases, as such inferences could then not be cancelled, given the monotonic semantics of RDF.
An intermediate alternative would be to make quoted triples referentially opaque for IRIs only, keeping it transparent for literals (and for blank nodes, as is already the case). This can be achieved by changing the step 2.4 of the unstar mapping algorithm as follows:
This section is non-normative.
In this section, we propose a minimal vocabulary that can be useful when working with RDF-star, especially when describing other vocabularies meant to be used with RDF-star triples and graphs.
In this section we define IRIs for the concepts defined in other normative parts of this document.
rdf-star:Triple
rdfs:domain
or
rdfs:range
of
properties
meant
to
apply
to
quoted
triples
.
rdf-star:Graph
rdf-star:Source
rdf-star:SPARQLStarQuery
sd:supportedLanguage
in
SPARQL
service
descriptions
[
SPARQL11-SERVICE-DESCRIPTION
].
rdf-star:SPARQLStarUpdate
sd:supportedLanguage
in
SPARQL
service
descriptions
[
SPARQL11-SERVICE-DESCRIPTION
].
Below is a Turtle description of that vocabulary.
## RDF-star core vocabulary
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf-star: <http://www.w3.org/ns/rdf-star#>
PREFIX sd: <http://www.w3.org/ns/sparql-service-description#>
rdf-star:Triple a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/ns/rdf-star#> ;
rdfs:label "RDF-star Triple" ;
rdfs:comment "The class of RDF-star triples." ;
rdfs:subClassOf rdfs:Resource .
rdf-star:Graph a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/ns/rdf-star#> ;
rdfs:label "RDF-star Graph" ;
rdfs:comment "The class of RDF-star graphs." ;
rdfs:subClassOf rdfs:Resource .
rdf-star:Source a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/ns/rdf-star#> ;
rdfs:label "RDF-star Source" ;
rdfs:seeAlso <https://www.w3.org/TR/rdf11-concepts/#h3_change-over-time> ;
rdfs:comment "The class of RDF-star sources." ;
rdfs:subClassOf rdfs:Resource .
rdf-star:SPARQLStarQuery a sd:Language ;
rdfs:isDefinedBy <http://www.w3.org/ns/rdf-star#> ;
rdfs:label "SPARQL-star" ;
rdfs:comment "The SPARQL-star query language" .
rdf-star:SPARQLStarUpdate a sd:Language ;
rdfs:isDefinedBy <http://www.w3.org/ns/rdf-star#> ;
rdfs:label "SPARQL-star Update" ;
rdfs:comment
"The
SPARQL-star
update
language"
.
In this section we define IRIs for the concepts defined in other non-normative parts of this document.
rdf-star:TransparencyEnablingProperty
Below is a Turtle description of that vocabulary.
## RDF-star extended vocabulary
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf-star: <http://www.w3.org/ns/rdf-star#>
rdf-star:TransparencyEnablingProperty a rdfs:Class ;
rdfs:isDefinedBy <http://www.w3.org/ns/rdf-star#> ;
rdfs:label "RDF-star Source" ;
rdfs:comment "The class of transparency-enabling properties." ;
rdfs:subClassOf
rdf:Property
.
We now describe a semantic extension of RDF-star, embedding the inherent semantics of the RDF-star vocabulary (RSV) described above (core and extended). A simple RSV-interpretation is a simple interpretation I that satisfies the following additional conditions:
rdf-star:Triple
.
unstar:subject
)),
unstar:predicate
)),
unstar:object
)),
unstar:subjectLexical
)),
unstar:predicateLexical
)),
unstar:objectLexical
)),
rdf-star:Triple
))
must
be
an
element
of
IEXT(IS(
rdf:type
)).
unstar:subject
)),
unstar:predicate
)),
unstar:object
)),
unstar:subject
)),
unstar:predicate
)),
unstar:object
)),
unstar:subjectLexical
)),
unstar:predicateLexical
)),
and
unstar:objectLexical
)).
rdf-star:TransparencyEnablingProperty
))
∈
IEXT(IS(
rdf:type
))
p
)
unstar:subject
)),
unstar:predicate
)),
unstar:object
)),
unstar:subject
)),
unstar:predicate
)),
unstar:object
))
p
)
unstar:subject
)),
unstar:predicate
)),
unstar:object
)),
unstar:subject
)),
unstar:predicate
)),
unstar:object
))
Given two RDF-star graphs G and H , and following standard terminology, we say that a simple RSV-interpretation I satisfies G if I ( G ) = true, and that G is (simply) RSV-satisfiable if a simple RSV-interpretation exists that satisfies G ; otherwise, G is (simply) RSV-unsatisfiable. We say that G simply RSV-entails H if every simple RSV-interpretation that satisfies G also satisfies H . If G and H each RSV-entail the other, they are RSV-equivalent.
RSV-entailment is defined here as an extension of simple entailment , but other entailment regimes (such as RDF entailment or RDFS entailment ) can be extended in the exact same way (i.e., by extending their respective notion of interpretation with the aforementioned conditions).
Some
terms
of
the
RDF-star
vocabulary
have
no
associated
constraint
in
RSV-interpretations
(for
instance,
rdf-star:Graph
).
The
reason
is
that
the
intended
meaning
of
these
terms
leads
to
no
particular
inference
with
this
vocabulary
.
This section is non-normative.
In
3.
Concrete
Syntaxes
,
we
have
proposed
extensions
to
four
existing
media
types,
namely
text/turtle
[
TURTLE
],
application/trig
[
TRIG
],
application/n-triples
[
N-TRIPLES
]
and
application/n-quads
[
N-QUADS
].
In
4.
SPARQL-star
Query
Language
,
we
have
proposed
extensions
to
three
more
existing
media
types,
namely
application/sparql-query
[
SPARQL11-QUERY
],
application/sparql-results+json
[
SPARQL11-RESULTS-JSON
],
and
application/sparql-result+xml
[
RDF-SPARQL-XMLRES
].
While
the
RDF-DEV
Community
Group
has
no
authority
to
officially
update
these
media-types,
we
hope
that
a
future
working
group
with
such
authority
will
consider
doing
so,
and
include
extensions
proposed
in
this
report.
In the meantime, implementers of RDF-star are faced with a dilemma: use the standard media-type identifiers as if their definition had been already updated (optimistic approach); or make it explicit that they are prone to produce or consume quoted triples (pessimistic approach), perhaps by using a different temporary media-type, or custom HTTP headers.
The
optimistic
approach
raises
the
risk
of
breaking
the
expectations
of
other
applications
that
are
not
RDF-star-aware.
For
example,
if
a
SPARQL-star
endpoint
responds
to
a
CONSTRUCT
query
with
the
text/turtle
media-type,
and
includes
a
quoted
triple
in
the
response,
a
legacy
client
will
fail
to
parse
that
response.
On
the
other
hand,
if
the
same
server
applies
the
pessimistic
approach,
it
may
simply
reject
any
query
requiring
text/turtle
,
just
in
case
the
result
contain
quoted
triples
.
Note
that
it
is
not
always
feasible
for
the
server
to
decide
beforehand
whether
the
result
is
plain
Turtle
or
Turtle-star,
because
the
result
is
often
produced
in
a
streamed
manner,
after
the
headers
containing
the
media-type
have
been
sent
to
the
client.
Another problem with the pessimistic approach is that "temporary" media-types are known to actually become permanent. Old applications keep using them long after their intended expiration date. This a burden on all other implementations, which must handle the "temporary" media-types along the permanent one, as aliases, in order to maintain backward compatibility.
The
W3C
Recommendation
Content
Negotiation
by
Profile
[
DX-PROF-CONNEG
]
describes
a
mechanism
that
separates
content-type
negotiation
from
requesting
a
response
conforming
to
a
specific
information
model,
whether
that
model
is
a
specific
standard,
specification
or
profile.
The
operations
of
the
abstract
model
are
"list
profiles"
and
"get
resource
by
profile".
The
"get
resource"
operation
can
provide
the
profile
requests
with
HTTP
header
Accept-Profile
and
responses
use
Content-Profile
,
or
alternatively
the
request
can
use
HTTP
Query
String
parameters.
This may be useful when the information is available in RDF-star or in non-RDF-star RDF 1.1 form, whether using reification, or by omitting information expressed with the RDF-star data model and responding with a restricted response. By lifting the issue up to the information model, away from being purely about syntax, restricted responses can be requested and returned which do not use RDF-star features. However, it assumes both requestor and receiver adhere to the defined profile negotiation and therefore does not address the dilemma of optimistic or pessimistic approaches.
Although the examples in this document, and the tests in the test suite , adopt the optimistic approach, it should be noted that no clear consensus emerged from the group on which approach is the best.
This section is non-normative.
A lot of discussions on the RDF-star mailing list and GitHub repository refer to SA-mode and PG-mode. Those abbreviations stand for "Separate Assertion mode" and "Property Graph mode". They originate in the fact that different versions of RDF-star have been published over the years, with different designs. In PG-mode, any quoted triple was also considered asserted . SA-mode, on the other hand, allowed the use of quoted triples without those triples being automatically asserted , requiring that they be asserted separately when that was intended. SA-mode was more flexible, but induced redundancy in the use-cases that PG-mode was designed to address.
The notion of annotations in the Turtle-star syntax was introduced to remove the need for different modes. Rather than interpret the same syntax differently in each mode, which would have caused interoperability problems and required a switch for those modes, it was decided to provide a different syntax for each use case.
<<
...
>>
syntax
represents
a
triple
that
is
quoted
without
being
asserted
,
satisfying
the
need
formerly
filled
by
SA-mode.
:a
:b
:c
{|
:p
:o
...
|}
annotation
syntax
creates
triples
where
the
subject
is
a
quoted
version
of
the
triple
asserted
just
before
the
annotation
(here,
:a
:b
:c
),
without
the
need
to
repeat
it,
satisfying
the
need
formerly
filled
by
PG-mode.
The motivating example in the original RDF-star paper [ RDF-STAR-FOUNDATION ] was on a provenance use-case, and is repeated below.
# the controversial seminal example :bob foaf:name "Bob". <<:bob foaf:age 23>> dct:creator <http://example.com/crawlers#c1> ; dct:source <http://example.net/listing.html> .
This
example
was
further
debated
on
the
RDF-star
mailing
list
,
as
it
appears
to
have
set
wrong
expectations
about
what
quoted
triples
represent.
More
precisely,
from
this
example,
one
may
wrongly
assume
that
<<:bob
foaf:age
23>>
represents
the
occurrence
of
the
given
triple
at
the
address
http://example.net/listing.html
(see
2.3
Triples
and
occurrences
).
This
impression
may
be
reinforced
by
the
use
of
dct:creator
:
arguably,
a
triple
(as
a
unique
abstract
entity)
is
not
"created"
by
anyone,
while
an
occurrence
thereof
can
be
said
to
be
created
or
authored.
The problem with this interpretation is that it will break as soon as other creators and sources are added for the triple: one could not tell which source corresponds to which creator. Correctly capturing this information would require additional nodes to explicitly represent triple occurrences, as in Example 8 . In summary, although RDF-star can be used for provenance, the seminal example does not work as stated and can lead to the fundamentally incorrect interpretation that RDF-star can represent multiple distinct quoted triples with the same subject, predicate, and object.
This section is non-normative.
The following is a complete grammar for Turtle-Star. The EBNF used here is defined in XML 1.0 [ EBNF-NOTATION ].
| [1] |
turtleDoc
| ::= |
statement
*
|
| [2] |
statement
| ::= |
directive
|
(
triples
"
.
"
)
|
| [3] |
directive
| ::= |
prefixID
|
base
|
sparqlPrefix
|
sparqlBase
|
| [4] |
prefixID
| ::= |
"@prefix"
PNAME_NS
IRIREF
"
.
"
?
|
| [5] |
base
| ::= |
"@base"
IRIREF
"
.
"
?
|
| [5s] |
sparqlPrefix
| ::= | "PREFIX" PNAME_NS IRIREF |
| [6s] |
sparqlBase
| ::= | "BASE" IRIREF |
| [6] |
triples
| ::= |
(
subject
predicateObjectList
)
|
(
blankNodePropertyList
predicateObjectList
?
)
|
| [7] |
predicateObjectList
| ::= |
verb
objectList
(
"
;
"
(
verb
objectList
)
?
)
*
|
| [8] |
objectList
| ::= |
object
annotation
?
(
"
,
"
object
annotation
?
)
*
|
| [9] |
verb
| ::= |
predicate
|
"
a
"
|
| [10] |
subject
| ::= |
iri
|
BlankNode
|
collection
|
quotedTriple
|
| [11] |
predicate
| ::= | iri |
| [12] |
object
| ::= |
iri
|
BlankNode
|
collection
|
blankNodePropertyList
|
literal
|
quotedTriple
|
| [13] |
literal
| ::= |
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
| [14] |
blankNodePropertyList
| ::= |
"
[
"
predicateObjectList
"
]
"
|
| [15] |
collection
| ::= |
"
(
"
object
*
"
)
"
|
| [16] |
NumericLiteral
| ::= |
INTEGER
|
DECIMAL
|
DOUBLE
|
| [128s] |
RDFLiteral
| ::= |
String
(
LANGTAG
|
(
"^^"
iri
)
)
?
|
| [133s] |
BooleanLiteral
| ::= |
"true"
|
"false"
|
| [17] |
String
| ::= |
STRING_LITERAL_QUOTE
|
STRING_LITERAL_SINGLE_QUOTE
|
STRING_LITERAL_LONG_SINGLE_QUOTE
|
STRING_LITERAL_LONG_QUOTE
|
| [135s] |
iri
| ::= |
IRIREF
|
PrefixedName
|
| [136s] |
PrefixedName
| ::= |
PNAME_LN
|
PNAME_NS
|
| [137s] |
BlankNode
| ::= |
BLANK_NODE_LABEL
|
ANON
|
| [27] |
quotedTriple
| ::= | "<<" qtSubject predicate qtObject ">>" |
| [28] |
qtSubject
| ::= |
iri
|
BlankNode
|
quotedTriple
|
| [29] |
qtObject
| ::= |
iri
|
BlankNode
|
literal
|
quotedTriple
|
| [30] |
annotation
| ::= | "{|" predicateObjectList "|}" |
| @terminals | # Productions for terminals | ||
| [18] |
IRIREF
| ::= |
"
<
"
(
[
^
#x00
-
#x20
<>"{}|^`\
]
|
UCHAR
)
*
"
>
"
|
| [139s] |
PNAME_NS
| ::= |
PN_PREFIX
?
"
:
"
|
| [140s] |
PNAME_LN
| ::= | PNAME_NS PN_LOCAL |
| [141s] |
BLANK_NODE_LABEL
| ::= |
"_:"
(
PN_CHARS_U
|
[
0-9
]
)
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [144s] |
LANGTAG
| ::= |
"
@
"
[
a-zA-Z
]
+
(
"
-
"
[
a-zA-Z0-9
]
+
)
*
|
| [19] |
INTEGER
| ::= |
[
+-
]
?
[
0-9
]
+
|
| [20] |
DECIMAL
| ::= |
[
+-
]
?
(
[
0-9
]
*
"
.
"
[
0-9
]
+
)
|
| [21] |
DOUBLE
| ::= |
[
+-
]
?
(
(
[
0-9
]
+
"
.
"
[
0-9
]
*
EXPONENT
)
|
(
"
.
"
[
0-9
]
+
EXPONENT
)
|
(
[
0-9
]
+
EXPONENT
)
)
|
| [154s] |
EXPONENT
| ::= |
[
eE
]
[
+-
]
?
[
0-9
]
+
|
| [22] |
STRING_LITERAL_QUOTE
| ::= |
'
"
'
(
[
^
>"
#x5C
#x0A
#x0D
]
|
ECHAR
|
UCHAR
)
*
'
"
'
|
| [23] |
STRING_LITERAL_SINGLE_QUOTE
| ::= |
"
'
"
(
[
^
#x27
#x5C
#x0A
#x0D
]
|
ECHAR
|
UCHAR
)
*
"
'
"
|
| [24] |
STRING_LITERAL_LONG_SINGLE_QUOTE
| ::= |
"'''"
(
(
"
'
"
|
"''"
)
?
(
[
^'\
]
|
ECHAR
|
UCHAR
)
)
*
"'''"
|
| [25] |
STRING_LITERAL_LONG_QUOTE
| ::= |
'"""'
(
(
'
"
'
|
'""'
)
?
(
[
^"\
]
|
ECHAR
|
UCHAR
)
)
*
'"""'
|
| [26] |
UCHAR
| ::= |
(
"\u"
HEX
HEX
HEX
HEX
)
|
(
"\U"
HEX
HEX
HEX
HEX
HEX
HEX
HEX
HEX
)
|
| [159s] |
ECHAR
| ::= |
"
\
"
[
tbnrf\"'
]
|
| [161s] |
WS
| ::= |
#x20
|
#x09
|
#x0D
|
#x0A
|
| [162s] |
ANON
| ::= |
"
[
"
WS
*
"
]
"
|
| [163s] |
PN_CHARS_BASE
| ::= |
[
A-Z
]
|
| | |
[
a-z
]
| ||
| | |
[
#xC0
-
#xD6
]
| ||
| | |
[
#xD8
-
#xF6
]
| ||
| | |
[
#xF8
-
#x02FF
]
| ||
| | |
[
#x0370
-
#x037D
]
| ||
| | |
[
#x037F
-
#x1FFF
]
| ||
| | |
[
#x200C
-
#x200D
]
| ||
| | |
[
#x2070
-
#x218F
]
| ||
| | |
[
#x2C00
-
#x2FEF
]
| ||
| | |
[
#x3001
-
#xD7FF
]
| ||
| | |
[
#xF900
-
#xFDCF
]
| ||
| | |
[
#xFDF0
-
#xFFFD
]
| ||
| | |
[
#x00010000
-
#x000EFFFF
]
| ||
| [164s] |
PN_CHARS_U
| ::= |
PN_CHARS_BASE
|
"
_
"
|
| [166s] |
PN_CHARS
| ::= |
PN_CHARS_U
|
"
-
"
|
[
0-9
]
|
#xB7
|
[
#x0300
-
#x036F
]
|
[
#x203F
-
#x2040
]
|
| [167s] |
PN_PREFIX
| ::= |
PN_CHARS_BASE
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [168s] |
PN_LOCAL
| ::= |
(
PN_CHARS_U
|
"
:
"
|
[
0-9
]
|
PLX
)
(
(
PN_CHARS
|
"
.
"
|
"
:
"
|
PLX
)
*
(
PN_CHARS
|
"
:
"
|
PLX
)
)
?
|
| [169s] |
PLX
| ::= |
PERCENT
|
PN_LOCAL_ESC
|
| [170s] |
PERCENT
| ::= |
"
%
"
HEX
HEX
|
| [171s] |
HEX
| ::= |
[
0-9
]
|
[
A-F
]
|
[
a-f
]
|
| [172s] |
PN_LOCAL_ESC
| ::= |
"
\
"
(
"
_
"
|
"
~
"
|
"
.
"
|
"
-
"
|
"
!
"
|
"
$
"
|
"
&
"
|
"
'
"
|
"
(
"
|
"
)
"
|
"
*
"
|
"
+
"
|
"
,
"
|
"
;
"
|
"
=
"
|
"
/
"
|
"
?
"
|
"
#
"
|
"
@
"
|
"
%
"
)
|
This section is non-normative.
The following is a complete grammar for TriG-Star. The EBNF used here is defined in XML 1.0 [ EBNF-NOTATION ].
| [1g] |
trigDoc
|
::= |
(
directive
|
block
)
*
|
| [2g] |
block
|
::= |
triplesOrGraph
|
wrappedGraph
|
triples2
|
(
"GRAPH"
labelOrSubject
wrappedGraph
)
|
| [3g] |
triplesOrGraph
|
::= |
(
labelOrSubject
(
wrappedGraph
|
(
predicateObjectList
"
.
"
)
)
)
|
(
quotedTriple
predicateObjectList
"
.
"
)
|
| [4g] |
triples2
|
::= |
(
blankNodePropertyList
predicateObjectList
?
"
.
"
)
|
(
collection
predicateObjectList
"
.
"
)
|
| [5g] |
wrappedGraph
|
::= |
"
{
"
triplesBlock
?
"
}
"
|
| [6g] |
triplesBlock
|
::= |
triples
(
"
.
"
triplesBlock
?
)
?
|
| [7g] |
labelOrSubject
|
::= |
iri
|
BlankNode
|
| [3] |
directive
|
::= |
prefixID
|
base
|
sparqlPrefix
|
sparqlBase
|
| [4] |
prefixID
|
::= |
"@prefix"
PNAME_NS
IRIREF
"
.
"
?
|
| [5] |
base
|
::= |
"@base"
IRIREF
"
.
"
?
|
| [5s] |
sparqlPrefix
|
::= | "PREFIX" PNAME_NS IRIREF |
| [6s] |
sparqlBase
|
::= | "BASE" IRIREF |
| [6] |
triples
|
::= |
(
subject
predicateObjectList
)
|
(
blankNodePropertyList
predicateObjectList
?
)
|
| [7] |
predicateObjectList
|
::= |
verb
objectList
(
"
;
"
(
verb
objectList
)
?
)
*
|
| [8] |
objectList
|
::= |
object
annotation
?
(
"
,
"
object
annotation
?
)
*
|
| [9] |
verb
|
::= |
predicate
|
"
a
"
|
| [10] |
subject
|
::= |
iri
|
blank
|
quotedTriple
|
| [11] |
predicate
|
::= | iri |
| [12] |
object
|
::= |
iri
|
blank
|
blankNodePropertyList
|
literal
|
quotedTriple
|
| [13] |
literal
|
::= |
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
| [14] |
blank
|
::= |
BlankNode
|
collection
|
| [15] |
blankNodePropertyList
|
::= |
"
[
"
predicateObjectList
"
]
"
|
| [16] |
collection
|
::= |
"
(
"
object
*
"
)
"
|
| [17] |
NumericLiteral
|
::= |
INTEGER
|
DECIMAL
|
DOUBLE
|
| [128s] |
RDFLiteral
|
::= |
String
(
LANGTAG
|
(
"^^"
iri
)
)
?
|
| [133s] |
BooleanLiteral
|
::= |
"true"
|
"false"
|
| [18] |
String
|
::= |
STRING_LITERAL_QUOTE
|
STRING_LITERAL_SINGLE_QUOTE
|
STRING_LITERAL_LONG_SINGLE_QUOTE
|
STRING_LITERAL_LONG_QUOTE
|
| [135s] |
iri
|
::= |
IRIREF
|
PrefixedName
|
| [136s] |
PrefixedName
|
::= |
PNAME_LN
|
PNAME_NS
|
| [137s] |
BlankNode
|
::= |
BLANK_NODE_LABEL
|
ANON
|
| [27] |
quotedTriple
|
::= | "<<" qtSubject predicate qtObject ">>" |
| [28] |
qtSubject
|
::= |
iri
|
BlankNode
|
quotedTriple
|
| [29] |
qtObject
|
::= |
iri
|
BlankNode
|
literal
|
quotedTriple
|
| [30] |
annotation
|
::= | "{|" predicateObjectList "|}" |
| @terminals | # Productions for terminals | ||
| [19] |
IRIREF
|
::= |
"
<
"
(
[
^
#x00
-
#x20
<>"{}|^`\
]
|
UCHAR
)
*
"
>
"
|
| [139s] |
PNAME_NS
|
::= |
PN_PREFIX
?
"
:
"
|
| [140s] |
PNAME_LN
|
::= | PNAME_NS PN_LOCAL |
| [141s] |
BLANK_NODE_LABEL
|
::= |
"_:"
(
PN_CHARS_U
|
[
0-9
]
)
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [144s] |
LANGTAG
|
::= |
"
@
"
[
a-zA-Z
]
+
(
"
-
"
[
a-zA-Z0-9
]
+
)
*
|
| [20] |
INTEGER
|
::= |
[
+-
]
?
[
0-9
]
+
|
| [21] |
DECIMAL
|
::= |
[
+-
]
?
(
[
0-9
]
*
"
.
"
[
0-9
]
+
)
|
| [22] |
DOUBLE
|
::= |
[
+-
]
?
(
(
[
0-9
]
+
"
.
"
[
0-9
]
*
EXPONENT
)
|
(
"
.
"
[
0-9
]
+
EXPONENT
)
|
(
[
0-9
]
+
EXPONENT
)
)
|
| [154s] |
EXPONENT
|
::= |
[
eE
]
[
+-
]
?
[
0-9
]
+
|
| [23] |
STRING_LITERAL_QUOTE
|
::= |
'
"
'
(
[
^
>"
#x5C
#x0A
#x0D
]
|
ECHAR
|
UCHAR
)
*
'
"
'
|
| [24] |
STRING_LITERAL_SINGLE_QUOTE
|
::= |
"
'
"
(
[
^
#x27
#x5C
#x0A
#x0D
]
|
ECHAR
|
UCHAR
)
*
"
'
"
|
| [25] |
STRING_LITERAL_LONG_SINGLE_QUOTE
|
::= |
"'''"
(
(
"
'
"
|
"''"
)
?
(
[
^'\
]
|
ECHAR
|
UCHAR
)
)
*
"'''"
|
| [26] |
STRING_LITERAL_LONG_QUOTE
|
::= |
'"""'
(
(
'
"
'
|
'""'
)
?
(
[
^"\
]
|
ECHAR
|
UCHAR
)
)
*
'"""'
|
| [27] |
UCHAR
|
::= |
(
"\u"
HEX
HEX
HEX
HEX
)
|
(
"\U"
HEX
HEX
HEX
HEX
HEX
HEX
HEX
HEX
)
|
| [159s] |
ECHAR
|
::= |
"
\
"
[
tbnrf\"'
]
|
| [160s] |
NIL
|
::= |
"
(
"
WS
*
"
)
"
|
| [161s] |
WS
|
::= |
#x20
|
#x09
|
#x0D
|
#x0A
|
| [162s] |
ANON
|
::= |
"
[
"
WS
*
"
]
"
|
| [163s] |
PN_CHARS_BASE
|
::= |
[
A-Z
]
|
| | |
[
a-z
]
|
||
| | |
[
#xC0
-
#xD6
]
|
||
| | |
[
#xD8
-
#xF6
]
|
||
| | |
[
#xF8
-
#x02FF
]
|
||
| | |
[
#x0370
-
#x037D
]
|
||
| | |
[
#x037F
-
#x1FFF
]
|
||
| | |
[
#x200C
-
#x200D
]
|
||
| | |
[
#x2070
-
#x218F
]
|
||
| | |
[
#x2C00
-
#x2FEF
]
|
||
| | |
[
#x3001
-
#xD7FF
]
|
||
| | |
[
#xF900
-
#xFDCF
]
|
||
| | |
[
#xFDF0
-
#xFFFD
]
|
||
| | |
[
#x00010000
-
#x000EFFFF
]
|
||
| [164s] |
PN_CHARS_U
|
::= |
PN_CHARS_BASE
|
"
_
"
|
| [166s] |
PN_CHARS
|
::= |
PN_CHARS_U
|
"
-
"
|
[
0-9
]
|
#xB7
|
[
#x0300
-
#x036F
]
|
[
#x203F
-
#x2040
]
|
| [167s] |
PN_PREFIX
|
::= |
PN_CHARS_BASE
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [168s] |
PN_LOCAL
|
::= |
(
PN_CHARS_U
|
"
:
"
|
[
0-9
]
|
PLX
)
(
(
PN_CHARS
|
"
.
"
|
"
:
"
|
PLX
)
*
(
PN_CHARS
|
"
:
"
|
PLX
)
)
?
|
| [169s] |
PLX
|
::= |
PERCENT
|
PN_LOCAL_ESC
|
| [170s] |
PERCENT
|
::= |
"
%
"
HEX
HEX
|
| [171s] |
HEX
|
::= |
[
0-9
]
|
[
A-F
]
|
[
a-f
]
|
| [172s] |
PN_LOCAL_ESC
|
::= |
"
\
"
(
"
_
"
|
"
~
"
|
"
.
"
|
"
-
"
|
"
!
"
|
"
$
"
|
"
&
"
|
"
'
"
|
"
(
"
|
"
)
"
|
"
*
"
|
"
+
"
|
"
,
"
|
"
;
"
|
"
=
"
|
"
/
"
|
"
?
"
|
"
#
"
|
"
@
"
|
"
%
"
)
|
This section is non-normative.
The following is a complete grammar for N-Triples-Star. The EBNF used here is defined in XML 1.0 [ EBNF-NOTATION ].
| [1] |
ntriplesDoc
|
::= |
triple
?
(
EOL
triple
)
*
EOL
?
|
| [2] |
triple
|
::= |
subject
predicate
object
"
.
"
|
| [3] |
subject
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
quotedTriple
|
| [4] |
predicate
|
::= | IRIREF |
| [5] |
object
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
literal
|
quotedTriple
|
| [6] |
literal
|
::= |
STRING_LITERAL_QUOTE
(
(
"^^"
IRIREF
)
|
LANGTAG
)
?
|
| [7t] |
quotedTriple
|
::= | "<<" subject predicate object ">>" |
| @terminals | # Productions for terminals | ||
| [144s] |
LANGTAG
|
::= |
"
@
"
[
a-zA-Z
]
+
(
"
-
"
[
a-zA-Z0-9
]
+
)
*
|
| [7] |
EOL
|
::= |
[
#x0D
#x0A
]
+
|
| [8] |
IRIREF
|
::= |
"
<
"
(
[
^
#x00
-
#x20
<>"{}|^`\
]
|
UCHAR
)
*
"
>
"
|
| [9] |
STRING_LITERAL_QUOTE
|
::= |
'
"
'
(
[
^
>"
#x5C
#x0A
#x0D
]
|
ECHAR
|
UCHAR
)
*
'
"
'
|
| [141s] |
BLANK_NODE_LABEL
|
::= |
"_:"
(
PN_CHARS_U
|
[
0-9
]
)
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [10] |
UCHAR
|
::= |
(
"\u"
HEX
HEX
HEX
HEX
)
|
(
"\U"
HEX
HEX
HEX
HEX
HEX
HEX
HEX
HEX
)
|
| [153s] |
ECHAR
|
::= |
"
\
"
[
tbnrf"'\
]
|
| [157s] |
PN_CHARS_BASE
|
::= |
[
A-Z
]
|
| | |
[
a-z
]
|
||
| | |
[
#xC0
-
#xD6
]
|
||
| | |
[
#xD8
-
#xF6
]
|
||
| | |
[
#xF8
-
#x02FF
]
|
||
| | |
[
#x0370
-
#x037D
]
|
||
| | |
[
#x037F
-
#x1FFF
]
|
||
| | |
[
#x200C
-
#x200D
]
|
||
| | |
[
#x2070
-
#x218F
]
|
||
| | |
[
#x2C00
-
#x2FEF
]
|
||
| | |
[
#x3001
-
#xD7FF
]
|
||
| | |
[
#xF900
-
#xFDCF
]
|
||
| | |
[
#xFDF0
-
#xFFFD
]
|
||
| | |
[
#x00010000
-
#x000EFFFF
]
|
||
| [158s] |
PN_CHARS_U
|
::= |
PN_CHARS_BASE
|
"
_
"
|
"
:
"
|
| [160s] |
PN_CHARS
|
::= |
PN_CHARS_U
|
"
-
"
|
[
0-9
]
|
#xB7
|
[
#x0300
-
#x036F
]
|
[
#x203F
-
#x2040
]
|
| [162s] |
HEX
|
::= |
[
0-9
]
|
[
A-F
]
|
[
a-f
]
|
This section is non-normative.
The following is a complete grammar for N-Quads-Star. The EBNF used here is defined in XML 1.0 [ EBNF-NOTATION ].
| [1] |
nquadsDoc
|
::= |
statement
?
(
EOL
statement
)
*
EOL
?
|
| [2] |
statement
|
::= |
subject
predicate
object
graphLabel
"
.
"
|
| [3] |
subject
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
quotedTriple
|
| [4] |
predicate
|
::= | IRIREF |
| [5] |
object
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
literal
|
quotedTriple
|
| [6] |
graphLabel
|
::= |
IRIREF
|
BLANK_NODE_LABEL
|
| [7] |
literal
|
::= |
STRING_LITERAL_QUOTE
(
(
"^^"
IRIREF
)
|
LANGTAG
)
?
|
| [7t] |
quotedTriple
|
::= | "<<" subject predicate object ">>" |
| @terminals | # Productions for terminals | ||
| [144s] |
LANGTAG
|
::= |
"
@
"
[
a-zA-Z
]
+
(
"
-
"
[
a-zA-Z0-9
]
+
)
*
|
| [8] |
EOL
|
::= |
[
#x0D
#x0A
]
+
|
| [10] |
IRIREF
|
::= |
"
<
"
(
[
^
#x00
-
#x20
<>"{}|^`\
]
|
UCHAR
)
*
"
>
"
|
| [11] |
STRING_LITERAL_QUOTE
|
::= |
'
"
'
(
[
^
>"
#x5C
#x0A
#x0D
]
|
ECHAR
|
UCHAR
)
*
'
"
'
|
| [141s] |
BLANK_NODE_LABEL
|
::= |
"_:"
(
PN_CHARS_U
|
[
0-9
]
)
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [12] |
UCHAR
|
::= |
(
"\u"
HEX
HEX
HEX
HEX
)
|
(
"\U"
HEX
HEX
HEX
HEX
HEX
HEX
HEX
HEX
)
|
| [153s] |
ECHAR
|
::= |
"
\
"
[
tbnrf"'\
]
|
| [157s] |
PN_CHARS_BASE
|
::= |
[
A-Z
]
|
| | |
[
a-z
]
|
||
| | |
[
#xC0
-
#xD6
]
|
||
| | |
[
#xD8
-
#xF6
]
|
||
| | |
[
#xF8
-
#x02FF
]
|
||
| | |
[
#x0370
-
#x037D
]
|
||
| | |
[
#x037F
-
#x1FFF
]
|
||
| | |
[
#x200C
-
#x200D
]
|
||
| | |
[
#x2070
-
#x218F
]
|
||
| | |
[
#x2C00
-
#x2FEF
]
|
||
| | |
[
#x3001
-
#xD7FF
]
|
||
| | |
[
#xF900
-
#xFDCF
]
|
||
| | |
[
#xFDF0
-
#xFFFD
]
|
||
| | |
[
#x00010000
-
#x000EFFFF
]
|
||
| [158s] |
PN_CHARS_U
|
::= |
PN_CHARS_BASE
|
"
_
"
|
"
:
"
|
| [160s] |
PN_CHARS
|
::= |
PN_CHARS_U
|
"
-
"
|
[
0-9
]
|
#xB7
|
[
#x0300
-
#x036F
]
|
[
#x203F
-
#x2040
]
|
| [162s] |
HEX
|
::= |
[
0-9
]
|
[
A-F
]
|
[
a-f
]
|
This section is non-normative.
The following is a complete grammar for SPARQL-Star. The EBNF used here is defined in XML 1.0 [ EBNF-NOTATION ].
| [1] |
QueryUnit
|
::= | Query |
| [2] |
Query
|
::= |
Prologue
(
SelectQuery
|
ConstructQuery
|
DescribeQuery
|
AskQuery
)
ValuesClause
|
| [3] |
UpdateUnit
|
::= | Update |
| [4] |
Prologue
|
::= |
(
BaseDecl
|
PrefixDecl
)
*
|
| [5] |
BaseDecl
|
::= | "BASE" IRIREF |
| [6] |
PrefixDecl
|
::= | "PREFIX" PNAME_NS IRIREF |
| [7] |
SelectQuery
|
::= |
SelectClause
DatasetClause
*
WhereClause
SolutionModifier
|
| [8] |
SubSelect
|
::= | SelectClause WhereClause SolutionModifier ValuesClause |
| [9] |
SelectClause
|
::= |
"SELECT"
(
"DISTINCT"
|
"REDUCED"
)
?
(
(
Var
|
(
"
(
"
Expression
"AS"
Var
"
)
"
)
)
+
|
"
*
"
)
|
| [10] |
ConstructQuery
|
::= | "CONSTRUCT" |
(
(
ConstructTemplate
DatasetClause
*
WhereClause
SolutionModifier
)
(
DatasetClause
*
"WHERE"
"
{
"
TriplesTemplate
?
"
}
"
SolutionModifier
)
)
|
|||
| [11] |
DescribeQuery
|
::= |
"DESCRIBE"
(
VarOrIri
+
|
"
*
"
)
DatasetClause
*
WhereClause
?
SolutionModifier
|
| [12] |
AskQuery
|
::= |
"ASK"
DatasetClause
*
WhereClause
ValuesClause
|
| [13] |
DatasetClause
|
::= |
"FROM"
(
DefaultGraphClause
|
NamedGraphClause
)
|
| [14] |
DefaultGraphClause
|
::= | SourceSelector |
| [15] |
NamedGraphClause
|
::= | "NAMED" SourceSelector |
| [16] |
SourceSelector
|
::= | iri |
| [17] |
WhereClause
|
::= |
"WHERE"
?
GroupGraphPattern
|
| [18] |
SolutionModifier
|
::= |
GroupClause
?
HavingClause
?
OrderClause
?
LimitOffsetClauses
?
|
| [19] |
GroupClause
|
::= |
"GROUP"
"BY"
GroupCondition
+
|
| [20] |
GroupCondition
|
::= |
BuiltInCall
|
FunctionCall
|
(
"
(
"
Expression
(
"AS"
Var
)
?
"
)
"
)
|
Var
|
| [21] |
HavingClause
|
::= |
"HAVING"
HavingCondition
+
|
| [22] |
HavingCondition
|
::= | Constraint |
| [23] |
OrderClause
|
::= |
"ORDER"
"BY"
OrderCondition
+
|
| [24] |
OrderCondition
|
::= |
(
(
"ASC"
|
"DESC"
)
BrackettedExpression
)
|
(
Constraint
|
Var
)
|
| [25] |
LimitOffsetClauses
|
::= |
(
LimitClause
OffsetClause
?
)
|
(
OffsetClause
LimitClause
?
)
|
| [26] |
LimitClause
|
::= | "LIMIT" INTEGER |
| [27] |
OffsetClause
|
::= | "OFFSET" INTEGER |
| [28] |
ValuesClause
|
::= |
(
"VALUES"
DataBlock
)
?
|
| [29] |
Update
|
::= |
Prologue
(
Update1
(
"
;
"
Update
)
?
)
?
|
| [30] |
Update1
|
::= |
Load
|
Clear
|
Drop
|
Add
|
Move
|
Copy
|
Create
|
InsertData
|
DeleteData
|
DeleteWhere
|
Modify
|
| [31] |
Load
|
::= |
"LOAD"
"SILENT"
?
iri
(
"INTO"
GraphRef
)
?
|
| [32] |
Clear
|
::= |
"CLEAR"
"SILENT"
?
GraphRefAll
|
| [33] |
Drop
|
::= |
"DROP"
"SILENT"
?
GraphRefAll
|
| [34] |
Create
|
::= |
"CREATE"
"SILENT"
?
GraphRef
|
| [35] |
Add
|
::= |
"ADD"
"SILENT"
?
GraphOrDefault
"TO"
GraphOrDefault
|
| [36] |
Move
|
::= |
"MOVE"
"SILENT"
?
GraphOrDefault
"TO"
GraphOrDefault
|
| [37] |
Copy
|
::= |
"COPY"
"SILENT"
?
GraphOrDefault
"TO"
GraphOrDefault
|
| [38] |
InsertData
|
::= | "INSERT DATA" QuadData |
| [39] |
DeleteData
|
::= | "DELETE DATA" QuadData |
| [40] |
DeleteWhere
|
::= | "DELETE WHERE" QuadPattern |
| [41] |
Modify
|
::= |
(
"WITH"
iri
)
?
(
(
DeleteClause
InsertClause
?
)
|
InsertClause
)
UsingClause
*
"WHERE"
GroupGraphPattern
|
| [42] |
DeleteClause
|
::= | "DELETE" QuadPattern |
| [43] |
InsertClause
|
::= | "INSERT" QuadPattern |
| [44] |
UsingClause
|
::= |
"USING"
(
iri
|
(
"NAMED"
iri
)
)
|
| [45] |
GraphOrDefault
|
::= |
"DEFAULT"
|
(
"GRAPH"
?
iri
)
|
| [46] |
GraphRef
|
::= | "GRAPH" iri |
| [47] |
GraphRefAll
|
::= |
GraphRef
|
"DEFAULT"
|
"NAMED"
|
"ALL"
|
| [48] |
QuadPattern
|
::= |
"
{
"
Quads
"
}
"
|
| [49] |
QuadData
|
::= |
"
{
"
Quads
"
}
"
|
| [50] |
Quads
|
::= |
TriplesTemplate
?
(
QuadsNotTriples
"
.
"
?
TriplesTemplate
?
)
*
|
| [51] |
QuadsNotTriples
|
::= |
"GRAPH"
VarOrIri
"
{
"
TriplesTemplate
?
"
}
"
|
| [52] |
TriplesTemplate
|
::= |
TriplesSameSubject
(
"
.
"
TriplesTemplate
?
)
?
|
| [53] |
GroupGraphPattern
|
::= |
"
{
"
(
SubSelect
|
GroupGraphPatternSub
)
"
}
"
|
| [54] |
GroupGraphPatternSub
|
::= |
TriplesBlock
?
(
GraphPatternNotTriples
"
.
"
?
TriplesBlock
?
)
*
|
| [55] |
TriplesBlock
|
::= |
TriplesSameSubjectPath
(
"
.
"
TriplesBlock
?
)
?
|
| [56] |
GraphPatternNotTriples
|
::= |
GroupOrUnionGraphPattern
|
OptionalGraphPattern
|
MinusGraphPattern
|
GraphGraphPattern
|
ServiceGraphPattern
|
Filter
|
Bind
|
InlineData
|
| [57] |
OptionalGraphPattern
|
::= | " OPTIONAL " GroupGraphPattern |
| [58] |
GraphGraphPattern
|
::= | "GRAPH" VarOrIri GroupGraphPattern |
| [59] |
ServiceGraphPattern
|
::= |
"SERVICE"
"SILENT"
?
VarOrIri
GroupGraphPattern
|
| [60] |
Bind
|
::= |
"BIND"
"
(
"
Expression
"AS"
Var
"
)
"
|
| [61] |
InlineData
|
::= | "VALUES" DataBlock |
| [62] |
DataBlock
|
::= |
InlineDataOneVar
|
InlineDataFull
|
| [63] |
InlineDataOneVar
|
::= |
Var
"
{
"
DataBlockValue
*
"
}
"
|
| [64] |
InlineDataFull
|
::= |
(
NIL
|
(
"
(
"
Var
*
"
)
"
)
)
"
{
"
(
(
"
(
"
DataBlockValue
*
"
)
"
)
|
NIL
)
*
"
}
"
|
| [65] |
DataBlockValue
|
::= |
QuotedTriple
|
iri
|
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
"UNDEF"
|
| [66] |
MinusGraphPattern
|
::= | "MINUS" GroupGraphPattern |
| [67] |
GroupOrUnionGraphPattern
|
::= |
GroupGraphPattern
(
"UNION"
GroupGraphPattern
)
*
|
| [68] |
Filter
|
::= | "FILTER" Constraint |
| [69] |
Constraint
|
::= |
BrackettedExpression
|
BuiltInCall
|
FunctionCall
|
| [70] |
FunctionCall
|
::= | iri ArgList |
| [71] |
ArgList
|
::= |
NIL
|
(
"
(
"
"DISTINCT"
?
Expression
(
"
,
"
Expression
)
*
"
)
"
)
|
| [72] |
ExpressionList
|
::= |
NIL
|
(
"
(
"
Expression
(
"
,
"
Expression
)
*
"
)
"
)
|
| [73] |
ConstructTemplate
|
::= |
"
{
"
ConstructTriples
?
"
}
"
|
| [74] |
ConstructTriples
|
::= |
TriplesSameSubject
(
"
.
"
ConstructTriples
?
)
?
|
| [75] |
TriplesSameSubject
|
::= |
(
VarOrTermOrQuotedTP
PropertyListNotEmpty
)
|
(
TriplesNode
PropertyList
)
|
| [76] |
PropertyList
|
::= |
PropertyListNotEmpty
?
|
| [77] |
PropertyListNotEmpty
|
::= |
Verb
ObjectList
(
"
;
"
(
Verb
ObjectList
)
?
)
*
|
| [78] |
Verb
|
::= |
VarOrIri
|
"
a
"
|
| [79] |
ObjectList
|
::= |
Object
(
"
,
"
Object
)
*
|
| [80] |
Object
|
::= |
GraphNode
AnnotationPattern
?
|
| [81] |
TriplesSameSubjectPath
|
::= |
(
VarOrTermOrQuotedTP
PropertyListPathNotEmpty
)
|
(
TriplesNodePath
PropertyListPath
)
|
| [82] |
PropertyListPath
|
::= |
PropertyListPathNotEmpty
?
|
| [83] |
PropertyListPathNotEmpty
|
::= |
(
VerbPath
|
VerbSimple
)
ObjectListPath
(
"
;
"
(
(
VerbPath
|
VerbSimple
)
ObjectList
)
?
)
*
|
| [84] |
VerbPath
|
::= | Path |
| [85] |
VerbSimple
|
::= | Var |
| [86] |
ObjectListPath
|
::= |
ObjectPath
(
"
,
"
ObjectPath
)
*
|
| [87] |
ObjectPath
|
::= |
GraphNodePath
AnnotationPatternPath
?
|
| [88] |
Path
|
::= | PathAlternative |
| [89] |
PathAlternative
|
::= |
PathSequence
(
"
|
"
PathSequence
)
*
|
| [90] |
PathSequence
|
::= |
PathEltOrInverse
(
"
/
"
PathEltOrInverse
)
*
|
| [91] |
PathElt
|
::= |
PathPrimary
PathMod
?
|
| [92] |
PathEltOrInverse
|
::= |
PathElt
|
(
"
^
"
PathElt
)
|
| [93] |
PathMod
|
::= |
"
*
"
|
"
?
"
|
"
+
"
|
| [94] |
PathPrimary
|
::= |
iri
|
"
a
"
|
(
"
!
"
PathNegatedPropertySet
)
|
(
"
(
"
Path
"
)
"
)
|
| [95] |
PathNegatedPropertySet
|
::= |
PathOneInPropertySet
|
(
"
(
"
(
PathOneInPropertySet
(
"
|
"
PathOneInPropertySet
)
*
)
?
"
)
"
)
|
| [96] |
PathOneInPropertySet
|
::= |
iri
|
"
a
"
|
(
"
^
"
(
iri
|
"
a
"
)
)
|
| [97] |
Integer
|
::= | INTEGER |
| [98] |
TriplesNode
|
::= |
Collection
|
BlankNodePropertyList
|
| [99] |
BlankNodePropertyList
|
::= |
"
[
"
PropertyListNotEmpty
"
]
"
|
| [100] |
TriplesNodePath
|
::= |
CollectionPath
|
BlankNodePropertyListPath
|
| [101] |
BlankNodePropertyListPath
|
::= |
"
[
"
PropertyListPathNotEmpty
"
]
"
|
| [102] |
Collection
|
::= |
"
(
"
GraphNode
+
"
)
"
|
| [103] |
CollectionPath
|
::= |
"
(
"
GraphNodePath
+
"
)
"
|
| [104] |
GraphNode
|
::= |
VarOrTermOrQuotedTP
|
TriplesNode
|
| [105] |
GraphNodePath
|
::= |
VarOrTermOrQuotedTP
|
TriplesNodePath
|
| [106] |
VarOrTerm
|
::= |
Var
|
GraphTerm
|
| [107] |
VarOrIri
|
::= |
Var
|
iri
|
| [108] |
Var
|
::= |
VAR1
|
VAR2
|
| [109] |
GraphTerm
|
::= |
iri
|
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
BlankNode
|
NIL
|
| [110] |
Expression
|
::= | ConditionalOrExpression |
| [111] |
ConditionalOrExpression
|
::= |
ConditionalAndExpression
(
"||"
ConditionalAndExpression
)
*
|
| [112] |
ConditionalAndExpression
|
::= |
ValueLogical
(
"&&"
ValueLogical
)
*
|
| [113] |
ValueLogical
|
::= | RelationalExpression |
| [114] |
RelationalExpression
|
::= | NumericExpression |
(
(
"
=
"
NumericExpression
)
(
"!="
NumericExpression
)
|
(
"
<
"
NumericExpression
)
|
(
"
>
"
NumericExpression
)
|
(
"<="
NumericExpression
)
|
(
">="
NumericExpression
)
|
(
"IN"
ExpressionList
)
|
(
"NOT"
"IN"
ExpressionList
)
)
?
|
|||
| [115] |
NumericExpression
|
::= | AdditiveExpression |
| [116] |
AdditiveExpression
|
::= | MultiplicativeExpression |
(
(
"
+
"
MultiplicativeExpression
)
(
"
-
"
MultiplicativeExpression
)
|
(
(
NumericLiteralPositive
|
NumericLiteralNegative
)
(
(
"
*
"
UnaryExpression
)
|
(
"
/
"
UnaryExpression
)
)
?
)
)
*
|
|||
| [117] |
MultiplicativeExpression
|
::= |
UnaryExpression
(
(
"
*
"
UnaryExpression
)
|
(
"
/
"
UnaryExpression
)
)
*
|
| [118] |
UnaryExpression
|
::= |
(
"
!
"
PrimaryExpression
)
|
(
"
+
"
PrimaryExpression
)
|
(
"
-
"
PrimaryExpression
)
|
PrimaryExpression
|
| [119] |
PrimaryExpression
|
::= |
BrackettedExpression
|
BuiltInCall
|
iriOrFunction
|
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
Var
|
ExprQuotedTP
|
| [120] |
BrackettedExpression
|
::= |
"
(
"
Expression
"
)
"
|
| [121] |
BuiltInCall
|
::= | Aggregate |
| | |
(
"STR"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"LANG"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"LANGMATCHES"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"DATATYPE"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"BOUND"
"
(
"
Var
"
)
"
)
|
||
| | |
(
"IRI"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"URI"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"BNODE"
(
(
"
(
"
Expression
"
)
"
)
|
NIL
)
)
|
||
| | |
(
"RAND"
NIL
)
|
||
| | |
(
"ABS"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"CEIL"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"FLOOR"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"ROUND"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"CONCAT"
ExpressionList
)
|
||
| | | SubstringExpression | ||
| | |
(
"STRLEN"
"
(
"
Expression
"
)
"
)
|
||
| | | StrReplaceExpression | ||
| | |
(
"UCASE"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"LCASE"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"ENCODE_FOR_URI"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"CONTAINS"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"STRSTARTS"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"STRENDS"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"STRBEFORE"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"STRAFTER"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"YEAR"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"MONTH"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"DAY"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"HOURS"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"MINUTES"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"SECONDS"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"TIMEZONE"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"TZ"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"NOW"
NIL
)
|
||
| | |
(
"UUID"
NIL
)
|
||
| | |
(
"STRUUID"
NIL
)
|
||
| | |
(
"MD5"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"SHA1"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"SHA224"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"SHA256"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"SHA384"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"SHA512"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"COALESCE"
ExpressionList
)
|
||
| | |
(
"IF"
"
(
"
Expression
"
,
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"STRLANG"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"STRDT"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"sameTerm"
"
(
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"isIRI"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"isURI"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"isBLANK"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"isLITERAL"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"isNUMERIC"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"TRIPLE"
"
(
"
Expression
"
,
"
Expression
"
,
"
Expression
"
)
"
)
|
||
| | |
(
"SUBJECT"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"PREDICATE"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"OBJECT"
"
(
"
Expression
"
)
"
)
|
||
| | |
(
"isTRIPLE"
"
(
"
Expression
"
)
"
)
|
||
| | | RegexExpression | ||
| | | ExistsFunc | ||
| | | NotExistsFunc | ||
| [122] |
RegexExpression
|
::= |
"REGEX"
"
(
"
Expression
"
,
"
Expression
(
"
,
"
Expression
)
?
"
)
"
|
| [123] |
SubstringExpression
|
::= |
"SUBSTR"
"
(
"
Expression
"
,
"
Expression
(
"
,
"
Expression
)
?
"
)
"
|
| [124] |
StrReplaceExpression
|
::= |
"REPLACE"
"
(
"
Expression
"
,
"
Expression
"
,
"
Expression
(
"
,
"
Expression
)
?
"
)
"
|
| [125] |
ExistsFunc
|
::= | "EXISTS" GroupGraphPattern |
| [126] |
NotExistsFunc
|
::= | "NOT" "EXISTS" GroupGraphPattern |
| [127] |
Aggregate
|
::= |
(
"COUNT"
"
(
"
"DISTINCT"
?
(
"
*
"
Expression
)
"
)
"
)
|
| | |
(
"SUM"
"
(
"
"DISTINCT"
?
Expression
"
)
"
)
|
||
| | |
(
"MIN"
"
(
"
"DISTINCT"
?
Expression
"
)
"
)
|
||
| | |
(
"MAX"
"
(
"
"DISTINCT"
?
Expression
"
)
"
)
|
||
| | |
(
"AVG"
"
(
"
"DISTINCT"
?
Expression
"
)
"
)
|
||
| | |
(
"SAMPLE"
"
(
"
"DISTINCT"
?
Expression
"
)
"
)
|
||
| | |
(
"GROUP_CONCAT"
"
(
"
"DISTINCT"
?
Expression
(
"
;
"
"SEPARATOR"
"
=
"
String
)
?
"
)
"
)
|
||
| [128] |
iriOrFunction
|
::= |
iri
ArgList
?
|
| [129] |
RDFLiteral
|
::= |
String
(
LANGTAG
|
(
"^^"
iri
)
)
?
|
| [130] |
NumericLiteral
|
::= |
NumericLiteralUnsigned
|
NumericLiteralPositive
|
NumericLiteralNegative
|
| [131] |
NumericLiteralUnsigned
|
::= |
INTEGER
|
DECIMAL
|
DOUBLE
|
| [132] |
NumericLiteralPositive
|
::= |
INTEGER_POSITIVE
|
DECIMAL_POSITIVE
|
DOUBLE_POSITIVE
|
| [133] |
NumericLiteralNegative
|
::= |
INTEGER_NEGATIVE
|
DECIMAL_NEGATIVE
|
DOUBLE_NEGATIVE
|
| [134] |
BooleanLiteral
|
::= |
"true"
|
"false"
|
| [135] |
String
|
::= |
STRING_LITERAL1
|
STRING_LITERAL2
|
STRING_LITERAL_LONG1
|
STRING_LITERAL_LONG2
|
| [136] |
iri
|
::= |
IRIREF
|
PrefixedName
|
| [137] |
PrefixedName
|
::= |
PNAME_LN
|
PNAME_NS
|
| [138] |
BlankNode
|
::= |
BLANK_NODE_LABEL
|
ANON
|
| [174] |
QuotedTP
|
::= | "<<" qtSubjectOrObject Verb qtSubjectOrObject ">>" |
| [175] |
QuotedTriple
|
::= |
"<<"
DataValueTerm
(
iri
|
"
a
"
)
DataValueTerm
">>"
|
| [176] |
qtSubjectOrObject
|
::= |
Var
|
BlankNode
|
iri
|
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
QuotedTP
|
| [177] |
DataValueTerm
|
::= |
iri
|
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
QuotedTriple
|
| [178] |
VarOrTermOrQuotedTP
|
::= |
Var
|
GraphTerm
|
QuotedTP
|
| [179] |
AnnotationPattern
|
::= | "{|" PropertyListNotEmpty "|}" |
| [180] |
AnnotationPatternPath
|
::= | "{|" PropertyListPathNotEmpty "|}" |
| [181] |
ExprQuotedTP
|
::= | "<<" ExprVarOrTerm Verb ExprVarOrTerm ">>" |
| [182] |
ExprVarOrTerm
|
::= |
iri
|
RDFLiteral
|
NumericLiteral
|
BooleanLiteral
|
Var
|
ExprQuotedTP
|
| @terminals | # Productions for terminals | ||
| [139] |
IRIREF
|
::= |
"
<
"
(
[
^<>"{}|^`\
]
-
[
#x00
-
#x20
]
)
*
"
>
"
|
| [140] |
PNAME_NS
|
::= |
PN_PREFIX
?
"
:
"
|
| [141] |
PNAME_LN
|
::= | PNAME_NS PN_LOCAL |
| [142] |
BLANK_NODE_LABEL
|
::= |
"_:"
(
PN_CHARS_U
|
[
0-9
]
)
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [143] |
VAR1
|
::= |
"
?
"
VARNAME
|
| [144] |
VAR2
|
::= |
"
$
"
VARNAME
|
| [145] |
LANGTAG
|
::= |
"
@
"
[
a-zA-Z
]
+
(
"
-
"
[
a-zA-Z0-9
]
+
)
*
|
| [146] |
INTEGER
|
::= |
[
0-9
]
+
|
| [147] |
DECIMAL
|
::= |
[
0-9
]
*
"
.
"
[
0-9
]
+
|
| [148] |
DOUBLE
|
::= |
(
[
0-9
]
+
"
.
"
[
0-9
]
*
EXPONENT
)
|
(
"
.
"
[
0-9
]
+
EXPONENT
)
|
(
[
0-9
]
+
EXPONENT
)
|
| [149] |
INTEGER_POSITIVE
|
::= |
"
+
"
INTEGER
|
| [150] |
DECIMAL_POSITIVE
|
::= |
"
+
"
DECIMAL
|
| [151] |
DOUBLE_POSITIVE
|
::= |
"
+
"
DOUBLE
|
| [152] |
INTEGER_NEGATIVE
|
::= |
"
-
"
INTEGER
|
| [153] |
DECIMAL_NEGATIVE
|
::= |
"
-
"
DECIMAL
|
| [154] |
DOUBLE_NEGATIVE
|
::= |
"
-
"
DOUBLE
|
| [155] |
EXPONENT
|
::= |
[
eE
]
[
+-
]
?
[
0-9
]
+
|
| [156] |
STRING_LITERAL1
|
::= |
"
'
"
(
[
^
#x27
#x5C
#x0A
#x0D
]
|
ECHAR
)
*
"
'
"
|
| [157] |
STRING_LITERAL2
|
::= |
'
"
'
(
[
^
>"
#x5C
#x0A
#x0D
]
|
ECHAR
)
*
'
"
'
|
| [158] |
STRING_LITERAL_LONG1
|
::= |
"'''"
(
(
"
'
"
|
"''"
)
?
(
[
^'\
]
|
ECHAR
)
)
*
"'''"
|
| [159] |
STRING_LITERAL_LONG2
|
::= |
'"""'
(
(
'
"
'
|
'""'
)
?
(
[
^"\
]
|
ECHAR
)
)
*
'"""'
|
| [160] |
ECHAR
|
::= |
"
\
"
[
tbnrf\"'
]
|
| [161] |
NIL
|
::= |
"
(
"
WS
*
"
)
"
|
| [162] |
WS
|
::= |
#x20
|
#x09
|
#x0D
|
#x0A
|
| [163] |
ANON
|
::= |
"
[
"
WS
*
"
]
"
|
| [164] |
PN_CHARS_BASE
|
::= |
[
A-Z
]
|
| | |
[
a-z
]
|
||
| | |
[
#xC0
-
#xD6
]
|
||
| | |
[
#xD8
-
#xF6
]
|
||
| | |
[
#xF8
-
#x02FF
]
|
||
| | |
[
#x0370
-
#x037D
]
|
||
| | |
[
#x037F
-
#x1FFF
]
|
||
| | |
[
#x200C
-
#x200D
]
|
||
| | |
[
#x2070
-
#x218F
]
|
||
| | |
[
#x2C00
-
#x2FEF
]
|
||
| | |
[
#x3001
-
#xD7FF
]
|
||
| | |
[
#xF900
-
#xFDCF
]
|
||
| | |
[
#xFDF0
-
#xFFFD
]
|
||
| | |
[
#x00010000
-
#x000EFFFF
]
|
||
| [165] |
PN_CHARS_U
|
::= |
PN_CHARS_BASE
|
"
_
"
|
| [166] |
VARNAME
|
::= |
(
PN_CHARS_U
|
[
0-9
]
)
(
PN_CHARS_U
|
[
0-9
]
|
#xB7
|
[
#x0300
-
#x036F
]
|
[
#x203F
-
#x2040
]
)
*
|
| [167] |
PN_CHARS
|
::= |
PN_CHARS_U
|
"
-
"
|
[
0-9
]
|
#xB7
|
[
#x0300
-
#x036F
]
|
[
#x203F
-
#x2040
]
|
| [168] |
PN_PREFIX
|
::= |
PN_CHARS_BASE
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [169] |
PN_LOCAL
|
::= |
(
PN_CHARS_U
|
[
0-9
]
)
(
(
PN_CHARS
|
"
.
"
)
*
PN_CHARS
)
?
|
| [170] |
PLX
|
::= |
PERCENT
|
PN_LOCAL_ESC
|
| [171] |
PERCENT
|
::= |
"
%
"
HEX
HEX
|
| [172] |
HEX
|
::= |
[
0-9
]
|
[
A-F
]
|
[
a-f
]
|
| [173] |
PN_LOCAL_ESC
|
::= |
"
\
"
(
"
_
"
|
"
~
"
|
"
.
"
|
"
-
"
|
"
!
"
|
"
$
"
|
"
&
"
|
"
'
"
|
"
(
"
|
"
)
"
|
"
*
"
|
"
+
"
|
"
,
"
|
"
;
"
|
"
=
"
|
"
/
"
|
"
?
"
|
"
#
"
|
"
@
"
|
"
%
"
)
|
This section is non-normative.
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in:
Referenced in: