Skip to content
Permalink
Browse files
Update RDF-star terminology
  • Loading branch information
afs committed Jan 12, 2022
1 parent b6027fe commit 4cd0557baa0461f139913d3766a7fca181853635
Showing 1 changed file with 26 additions and 18 deletions.
@@ -17,17 +17,18 @@ Example:
<< :john foaf:name "John Smith" >> dct:source <http://example/directory> .
```

The part `<< :john foaf:name "John Smith" >>` is an embedded triple and refers to the triple with subject `:john`, property `foaf:name` and object `"John Smith"`.
The part `<< :john foaf:name "John Smith" >>` is a quoted triple and refers to the triple with subject `:john`, property `foaf:name` and object `"John Smith"`.

Triple terms can be in the subject or object position.

Jena provides support for RDF-star and the related SPARQL-star.

* Turtle, N-Triples, TriG and N-Quads extended for Triple Terms syntax,
input and output. There is no output in RDF/XML.
* SPARQL extended with Triple Term syntax for graph matching
* SPARQL Result formats for JSON and XML extended to support Triple Terms in results.
* SPARQL extended with Triple Term syntax for graph matching.
* SPARQL Result formats for JSON and XML extended to support quoted triples in results.
* Support in the Model API.
* Translation to and from RDF reification.

All this is active by default in Fuseki.

@@ -38,13 +39,13 @@ as well as in-memory databases is supported.

## RDF-star

RDF-star syntax for embedded triples is added to the parsers for Turtle, N-Triples, TriG and N-Quads.
RDF-star syntax for quoted triples is added to the parsers for Turtle, N-Triples, TriG and N-Quads.

Datasets may have graphs that have embedded triples that refer to triples anywhere, not just in the same graph.
Datasets may have graphs that have quoted triples that refer to triples anywhere, not just in the same graph.

## SPARQL-star

Matches for embedded triples:
Matches for quoted triples:

```sparql
SELECT ?name { <<:john foaf:name ?name >> dct:source <http://example/directory> }
@@ -75,25 +76,24 @@ SELECT (<< ?s ?p ?o>> AS ?t) {
}
```

### SPARQL Functions related to embedded triples
### SPARQL Functions related to quoted triples

These functions cause an expression error if passed the wrong type of arguments. `afn:`
is a prefix for `<http://jena.apache.org/ARQ/function#>`.
These functions cause an expression error if passed the wrong type of arguments.

| Function | Description |
|----------------------|------------------------ |
| `TRIPLE(?s, ?p, ?o)` | Create an embedded triple from s/p/o |
| `isTRIPLE(?t)` | Return true if the argument value is an embedded triple |
| `SUBJECT(?t)` | Return the subject of the embedded triple |
| `PREDICATE(?t)` | Return the predicate (property) of the embedded triple |
| `OBJECT(?t)` | Return the object of the embedded triple |
| `TRIPLE(?s, ?p, ?o)` | Create a quoted triple from s/p/o |
| `isTRIPLE(?t)` | Return true if the argument value is a quoted triple |
| `SUBJECT(?t)` | Return the subject of the quoted triple |
| `PREDICATE(?t)` | Return the predicate (property) of the quoted triple |
| `OBJECT(?t)` | Return the object of the quoted triple |

### SPARQL results

The syntaxes for SPARQL results from a SELECT query, `application/sparql-results+json`,
`application/sparql-results+xml` are extended to include embedded triples:
`application/sparql-results+xml` are extended to include quoted triples:

The embedded triple `<< _:b0 <http://example/p> 123 >>` is encoded, in
The quoted triple `<< _:b0 <http://example/p> 123 >>` is encoded, in
`application/sparql-results+json` as:

```json
@@ -124,13 +124,21 @@ and similarly in `application/sparql-results+xml`:
## Model API
RDF-star embedded triples are treated as `Resource` to preserve the typed Model API.
RDF-star quoted triples are treated as `Resource` to preserve the typed Model API.
They occur in the subject and object positions.
A `Resource` contains a `Statement` object if the underlying RDF term is an RDF-star embedded triple.
A `Resource` contains a `Statement` object if the underlying RDF term is an RDF-star quoted triple.
New methods include:
* `Statement Resource.getStatement()`
* `Resource Model.createResource(Statement)`
* `Resource ResourceFactory.createStatement`
## Reification
`org.apache.jena.system.RDFStar` provides functions to translate RDF-star into
RDF reification, and translate it back again to RDF-star.
Translating back to RDF-star relies on the consistency constraint that there is
only one reification for each unique quoted triple term.

0 comments on commit 4cd0557

Please sign in to comment.