This is an automated email from the ASF dual-hosted git repository. andy pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/jena-site.git
commit 422c9408e2cc31ddc3bade2eedd207217a0cbfd6 Author: Bruno P. Kinoshita <[email protected]> AuthorDate: Sun Jun 15 17:04:37 2025 +0200 Apply monospace to every pre>code HTML element, set size to 1rem --- assets/sass/jena.scss | 4 ++ source/documentation/query/construct-quad.md | 82 +++++++++++++--------- .../query/generate-json-from-sparql.md | 4 ++ source/documentation/query/lateral-join.md | 14 ++-- 4 files changed, 65 insertions(+), 39 deletions(-) diff --git a/assets/sass/jena.scss b/assets/sass/jena.scss index dae371118..e7256268e 100644 --- a/assets/sass/jena.scss +++ b/assets/sass/jena.scss @@ -1,3 +1,5 @@ +@import 'static/css/bootstrap'; + /* Tables */ table td { vertical-align: top; @@ -29,6 +31,8 @@ pre { pre > code { color: inherit; background-color: inherit; + font-size: 1rem !important; + @extend .font-monospace; } /** diff --git a/source/documentation/query/construct-quad.md b/source/documentation/query/construct-quad.md index d4e8360f0..6cce8b39c 100644 --- a/source/documentation/query/construct-quad.md +++ b/source/documentation/query/construct-quad.md @@ -27,17 +27,19 @@ there are 2 forms for ARQ Construct Quad query: ### Complete Form - CONSTRUCT { - # Named graph - GRAPH :g { ?s :p ?o } - # Default graph - { ?s :p ?o } - # Default graph - :s ?p :o - } WHERE { - # SPARQL 1.1 WHERE Clause - ... - } +```sparql +CONSTRUCT { + # Named graph + GRAPH :g { ?s :p ?o } + # Default graph + { ?s :p ?o } + # Default graph + :s ?p :o +} WHERE { + # SPARQL 1.1 WHERE Clause + ... +} +``` The default graphs and the named graphs can be constructed within the `CONSTRUCT` clause in the above way. Note that, for constructing the named @@ -46,10 +48,12 @@ be constructed in the default graph can also be optional. ### Short Form - CONSTRUCT WHERE { - # Basic dataset pattern (only the default graph and the named graphs) - ... - } +```sparql +CONSTRUCT WHERE { + # Basic dataset pattern (only the default graph and the named graphs) + ... +} +``` A short form is provided for the case where the template and the pattern are the same and the pattern is just a basic dataset pattern (no `FILTER`s @@ -60,7 +64,7 @@ and no complex graph patterns are allowed in the short form). The keyword The normative definition of the syntax grammar of the query string is defined in this table: -<div style="font-family: monospace"> +<div class="font-monospace"> Rule | | Expression --------------------------|-----|------------------------ @@ -79,8 +83,10 @@ TriplesTemplate | ::= | TriplesSameSubject ( '.' TriplesTemplate? )? ARQ provides 2 additional methods in [QueryExecution](/documentation/javadoc/arq/org.apache.jena.arq/org/apache/jena/query/QueryExecution.html) for Construct Quad. - Iterator<Quad> QueryExecution.execConstructQuads() // allow duplication - Dataset QueryExecution.execConstructDataset() // no duplication +```java +Iterator<Quad> QueryExecution.execConstructQuads() // allow duplication +Dataset QueryExecution.execConstructDataset() // no duplication +``` One difference of the 2 methods is: The method of `execConstructQuads()` returns an `Iterator` of `Quad`, allowing duplication. @@ -88,26 +94,32 @@ But `execConstructDataset()` constructs the desired Dataset object with only uni In order to use these methods, it's required to switch on the query syntax of ARQ beforehand, when creating the `Query` object: - - Query query = QueryFactory.create(queryString, Syntax.syntaxARQ); + +```java +Query query = QueryFactory.create(queryString, Syntax.syntaxARQ); +``` If the query is supposed to construct only triples, not quads, the triples will be constructed in the default graph. For example: - String queryString = "CONSTRUCT { ?s ?p ?o } WHERE ... " - ... - // The graph node of the quads are the default graph (ARQ uses <urn:x-arq:DefaultGraphNode>). - Iterator<Quad> quads = qexec.execConstructQuads(); +```java +String queryString = "CONSTRUCT { ?s ?p ?o } WHERE ... " +... +// The graph node of the quads are the default graph (ARQ uses <urn:x-arq:DefaultGraphNode>). +Iterator<Quad> quads = qexec.execConstructQuads(); +``` If the query string stands for constructing quads while the method of `exeConstructTriples()` are called, it returns only the triples in the default graph of the `CONSTRUCT` query template. It's called a "projection" on the default graph. For instance: - String queryString = "CONSTRUCT { ?s ?p ?o . GRAPH ?g1 { ?s1 ?p1 ?o1 } } WHERE ..." - ... - // The part of "GRAPH ?g1 { ?s1 ?p1 ?o1 }" will be ignored. Only "?s ?p ?o" in the default graph will be returned. - Iterator<Triple> triples = qexec.execConstructTriples(); +```java +String queryString = "CONSTRUCT { ?s ?p ?o . GRAPH ?g1 { ?s1 ?p1 ?o1 } } WHERE ..." +... +// The part of "GRAPH ?g1 { ?s1 ?p1 ?o1 }" will be ignored. Only "?s ?p ?o" in the default graph will be returned. +Iterator<Triple> triples = qexec.execConstructTriples(); +``` More examples can be found at `ExampleConstructQuads.java` at [jena-examples:arq/examples/constructquads/](https://github.com/apache/jena/tree/main/jena-examples/src/main/java/arq/examples/constructquads/). @@ -122,12 +134,14 @@ is just an implementation of QueryExecution, there's not much difference for the client users to manipulate the programming API described in the previous sections, e.g. - String queryString = " CONSTRUCT { GRAPH <http://example/ns#g1> {?s ?p ?o} } WHERE {?s ?p ?o}" ; - Query query = QueryFactory.create(queryString, Syntax.syntaxARQ); - try ( QueryExecution qExec = QueryExecution.service(serviceQuery).query(query).build() ) { // serviceQuery is the URL of the remote service - Iterator<Quad> result = qExec.execConstructQuads(); - ... - } +```java +String queryString = "CONSTRUCT { GRAPH <http://example/ns#g1> {?s ?p ?o} } WHERE {?s ?p ?o}"; +Query query = QueryFactory.create(queryString, Syntax.syntaxARQ); +try (QueryExecution qExec = QueryExecution.service(serviceQuery).query(query).build()) { // serviceQuery is the URL of the remote service + Iterator<Quad> result = qExec.execConstructQuads(); ... +} +... +``` [ARQ documentation index](index.html) diff --git a/source/documentation/query/generate-json-from-sparql.md b/source/documentation/query/generate-json-from-sparql.md index d81751d3e..dbfbd3b00 100644 --- a/source/documentation/query/generate-json-from-sparql.md +++ b/source/documentation/query/generate-json-from-sparql.md @@ -89,12 +89,16 @@ key/value pair pattern, which could produce the following output for the query a The normative definition of the syntax grammar of the query string is defined in this table: +<div class="font-monospace"> + Rule | | Expression --------------------------|-----|------------------------ JsonQuery | ::= | JsonClause ( DatasetClause )\* WhereClause SolutionModifier JsonClause | ::= | 'JSON' '\{' JsonObjectMember ( ',' JsonObjectMember )\* '\}' JsonObjectMember | ::= | String ':' ( Var | RDFLiteral | NumericLiteral | BooleanLiteral ) +</div> + `DatasetClause`, `WhereClause`, `SolutionModifier`, `String`, `Var`, 'RDFLiteral', `NumericLiteral`, and 'BooleanLiteral' are as for the [SPARQL 1.1 Grammar](http://www.w3.org/TR/sparql11-query/#grammar) diff --git a/source/documentation/query/lateral-join.md b/source/documentation/query/lateral-join.md index 52894590e..e04b75639 100644 --- a/source/documentation/query/lateral-join.md +++ b/source/documentation/query/lateral-join.md @@ -131,11 +131,15 @@ available to "pattern". This is similar to an SQL `LATERAL` is added to the SPARQL grammar at rule `[[56] GraphPatternNotTriples](https://www.w3.org/TR/sparql11-query/#rGraphPatternNotTriples)`. As a syntax form, it is similar to `OPTIONAL`. -```ebnf -[56] GraphPatternNotTriples ::= GroupOrUnionGraphPattern | OptionalGraphPattern | LateralGraphPattern | ... -[57] OptionalGraphPattern ::= 'OPTIONAL' GroupGraphPattern -[ ] LateralGraphPattern ::= 'LATERAL' GroupGraphPattern -``` +<div class="font-monospace"> + +ID | Rule | | Expression +-------|--------------------------|-----|------------------------ +[56] | GraphPatternNotTriples | ::= | GroupOrUnionGraphPattern | OptionalGraphPattern | LateralGraphPattern | ... +[57] | OptionalGraphPattern | ::= | 'OPTIONAL' GroupGraphPattern +[ ] | LateralGraphPattern | ::= | 'LATERAL' GroupGraphPattern + +</div> ### Algebra
