This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch jena4-updates in repository https://gitbox.apache.org/repos/asf/jena-site.git
commit 788daa80ce82c86ce9f0f1a668adeebfbfd87db2 Author: Andy Seaborne <[email protected]> AuthorDate: Tue Mar 2 22:22:46 2021 +0000 Redirect "rdfstar" to "rdf-star" --- source/documentation/rdf-star/__index.md | 118 +++++++++++++++++++++++++++++ source/documentation/rdfstar/__index.md | 126 ------------------------------- 2 files changed, 118 insertions(+), 126 deletions(-) diff --git a/source/documentation/rdf-star/__index.md b/source/documentation/rdf-star/__index.md new file mode 100644 index 0000000..dc7a3db --- /dev/null +++ b/source/documentation/rdf-star/__index.md @@ -0,0 +1,118 @@ +--- +title: Support of RDF-star +slug: index +aliases: + - /docimentation/rdfstar/ + - /documentation/rdfstar/index.html +--- +[RDF-star](https://w3c.github.io/rdf-star/) is an extension to RDF that provides +a way for one triple to refer to another triple. Another resource about RDF\* is +[Olaf Hartig's blog entry](https://blog.liu.se/olafhartig/2019/01/10/position-statement-rdf-star-and-sparql-star/). + +Example: + +```turtle +<< :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"`. + +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. There is no output in RDF/XML. +* SPARQL extended with Triple Term syntax for graph matching (in code, use `Syntax.syntaxARQ`). +* SPARQL Result formats for JSON and XML extended to support Triple Terms in results. +* Support in the Model API. + +All this is active by default in Fuseki. + +The aim is to follow the definition of the [RDF-star community](https://w3c.github.io/rdf-star/). + +Storage in databases [TDB1](/documentation/tdb) and [TDB2](/documentation/tdb2/) is supported as of Jena 3.16.0. + +## RDF-star + +RDF-star syntax for embedded 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. + +## SPARQL-star + +Matches for embedded triples: + +```sparql +SELECT ?name { <<:john foaf:name ?name >> dct:source <http://example/directory> } +``` + +Insert triples terms into the default graph to record the graph source. + +```sparql +INSERT { <<?s ?p ?o>> dct:source <http://example/directory> } +WHERE { + GRAPH <http://example/directory> { + ?s ?p ?o + } +} +``` + +### SPARQL Functions related to embedded 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#>`. + +| Keyword | Function | Description | +|--------------------| ------------------------ | ------------ | +| TRIPLE(?s, ?p, ?o) | `afn:triple(?s, ?p, ?o)` | Create an embedded triple from s/p/o | +| isTRIPLE(?t) | `afn:isTriple(?t)` | Return true if the argument value is an embedded triple | +| SUBJECT(?t) | `afn:subject(?t)` | Return the subject of the embedded triple | +| PREDICATE(?t) | `afn:predicate(?t)` | Return the predicate (property) of the embedded triple | +| OBJECT(?t) | `afn:object(?t)` | Return the object of the embedded 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: + +The embedded triple `<< _:b0 <http://example/p> 123 >>` is encoded, in +`application/sparql-results+json` as: + +```json + { + "type": "triple" , + "value": { + "subject": { "type": "bnode" , "value": "b0" } , + "predicate": { "type": "uri" , "value": "http://example/p" } , + "object": { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" } + } +``` + +and similarly in `application/sparql-results+xml`: + +```xml + <triple> + <subject> + <bnode>b0</bnode> + </subject> + <predicate> + <uri>http://example/p</uri> + </predicate> + <object> + <literal datatype="http://www.w3.org/2001/XMLSchema#integer">123</literal> + </object> + </triple> +``` + +## Model API + +RDF-star embedded 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* embedded triple. + +New methods include: + +* `Statement Resource.getStatement()` +* `Resource Model.createResource(Statement)` +* `Resource ResourceFactory.createStatement` diff --git a/source/documentation/rdfstar/__index.md b/source/documentation/rdfstar/__index.md deleted file mode 100644 index 0c53a47..0000000 --- a/source/documentation/rdfstar/__index.md +++ /dev/null @@ -1,126 +0,0 @@ ---- -title: Support of RDF* -slug: index ---- -[RDF\*](https://arxiv.org/abs/1406.3399) is an extension to RDF that provides -a way for one triple to refer to another triple. Another resource about RDF\* is -[Olaf Hartig's blog entry](https://blog.liu.se/olafhartig/2019/01/10/position-statement-rdf-star-and-sparql-star/). - -Example: - -```turtle -<< :john foaf:name "John Smith" >> dct:source <http://example/directory> . -``` - -The part `<< :john foaf:name "John Smith" >>` is a triple term 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\* and the related SPARQL\*. - -* Turtle, N-Triples, TriG and N-Quads extended for Triple Terms syntax. There is no output in RDF/XML. -* SPARQL extended with Triple Term syntax for graph matching (in code, use `Syntax.syntaxARQ`). -* SPARQL Result formats for JSON and XML extended to support Triple Terms in results. -* Support in the Model API. - -All this is active by default in Fuseki. - -The aim is to follow the definition of RDF* as well as emerging _de facto_ consensus in other implementations. - -Storage in databases [TDB1](/documentation/tdb) and [TDB2](/documentation/tdb2/) is supported as of Jena 3.16.0. - -## RDF\* - -RDF\* syntax for triple terms is added to the parsers for Turtle, N-Triples, TriG and N-Quads. - -Datasets may have graphs that have triple terms that refer to triples anywhere, not just in the same graph. - -## SPARQL\* - -Matches for triple terms: - -```sparql -SELECT ?name { <<:john foaf:name ?name >> dct:source <http://example/directory> } -``` - -Insert triples terms into the default graph to record the graph source. - -```sparql -INSERT { <<?s ?p ?o>> dct:source <http://example/directory> } -WHERE { - GRAPH <http://example/directory> { - ?s ?p ?o - } -} -``` - -### SPARQL Functions related to triple terms - -These functions cause an expression error if passed the wrong type of arguments. `afn:` -is a prefix for `<http://jena.apache.org/ARQ/function#>`. - -| Function | Description | -| -------- | ----------- | -| `afn:subject(?t)` | Return the subject of the triple term | -| `afn:predicate(?t)` | Return the predicate (property) of the triple term | -| `afn:object(?t)` | Return the object of the triple term | -| `afn:triple(?s, ?p, ?o)` | Create a triple term from s/p/o | -| `afn:isTriple(?t)` | Return true if the argument value is a triple term | - -### SPARQL Property Functions related to triple terms - -`apf:` is a prefix for `<http://jena.apache.org/ARQ/property#>`. - -| Property Function | Description | -| -------- | ----------- | -| `<< s p o >> apf:find t` . | Match the triple term. Any `s`, `p`, `o`, and `t` can be RDF terms or variables.| - -`apf:find` will result in all the variables being set according to the match, -If `t` is a variable, `?t`, it is bound to a triple term for the match of `<<s p o>>`. - -### SPARQL results - -The syntaxes for SPARQL results from a SELECT query, `application/sparql-results+json`, -`application/sparql-results+xml` are extended to include triple terms: - -The triple term `<< _:b0 <http://example/p> 123 >>` is encoded, in -`application/sparql-results+json` as: - -```json - { - "type": "triple" , - "value": { - "subject": { "type": "bnode" , "value": "b0" } , - "property": { "type": "uri" , "value": "http://example/p" } , - "object": { "type": "literal" , "datatype": "http://www.w3.org/2001/XMLSchema#integer" , "value": "123" } - } -``` - -and similarly in `application/sparql-results+xml`: - -```xml - <triple> - <subject> - <bnode>b0</bnode> - </subject> - <property> - <uri>http://example/p</uri> - </property> - <object> - <literal datatype="http://www.w3.org/2001/XMLSchema#integer">123</literal> - </object> - </triple> -``` - -## Model API - -RDF* triple terms 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* triple term. - -New methods include: - -* `Statement Resource.getStatement()` -* `Resource Model.createResource(Statement)` -* `Resource ResourceFactory.createStatement`
