You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2021/06/22 20:19:48 UTC

[jena-site] branch main updated: ShEx documentation (#59)

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


The following commit(s) were added to refs/heads/main by this push:
     new f969c3d  ShEx documentation (#59)
f969c3d is described below

commit f969c3d86ab55ddadd676f33b8f10f0b609b4b37
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Tue Jun 22 21:19:37 2021 +0100

    ShEx documentation (#59)
---
 layouts/_default/baseof.html          |  1 +
 source/documentation/__index.md       |  1 +
 source/documentation/javadoc.md       |  1 +
 source/documentation/shex/__index.md  | 86 +++++++++++++++++++++++++++++++++++
 source/documentation/tools/__index.md |  4 ++
 5 files changed, 93 insertions(+)

diff --git a/layouts/_default/baseof.html b/layouts/_default/baseof.html
index c5c7365..9067cd4 100644
--- a/layouts/_default/baseof.html
+++ b/layouts/_default/baseof.html
@@ -80,6 +80,7 @@
                         <li><a href="/documentation/tdb2/index.html">TDB2</a></li>
                         <li><a href="/documentation/query/text-query.html">Text Search</a></li>
                         <li><a href="/documentation/shacl/index.html">SHACL</a></li>
+                        <li><a href="/documentation/shex/index.html">ShEx</a></li>
                         <li><a href="/documentation/rdfstar/index.html">RDF-star</a></li>
                         <li><a href="/documentation/tools/index.html">Command-line tools</a></li>
                         <li><a href="/documentation/hadoop/index.html">Elephas - tools for RDF on Hadoop</a></li>
diff --git a/source/documentation/__index.md b/source/documentation/__index.md
index 4bb634c..3d5ac9e 100644
--- a/source/documentation/__index.md
+++ b/source/documentation/__index.md
@@ -22,6 +22,7 @@ sections.
 * [TDB2](./tdb2) - a fast persistent triple store that stores directly to disk
 * [TDB](./tdb/) - Original TDB database
 * [SHACL](./shacl) - SHACL processor for Jena
+* [ShEx](./shex) - ShEx processor for Jena
 * [Text Search](./query/text-query.html) - enhanced indexes using Lucene for more efficient searching of text literals in Jena models and datasets.
 * [GeoSPARQL](./geosparql/) - support for GeoSPARQL
 * [Permissions](./permissions/) - a permissions wrapper around Jena RDF implementation
diff --git a/source/documentation/javadoc.md b/source/documentation/javadoc.md
index 1e68acf..1412059 100644
--- a/source/documentation/javadoc.md
+++ b/source/documentation/javadoc.md
@@ -11,6 +11,7 @@ title: Jena JavaDoc
   - [Fuseki2 Main](javadoc/fuseki2-main/index.html)
 - [Text search](javadoc/text/index.html)
 - [SHACL](javadoc/shacl/index.html)
+- [ShEx](javadoc/shex/index.html)
 - [GeoSPARQL](javadoc/geosparql/index.html)
 - [Security Permissions JavaDoc](javadoc/permissions/index.html)
 - [JDBC JavaDoc](javadoc/jdbc/index.html)
diff --git a/source/documentation/shex/__index.md b/source/documentation/shex/__index.md
new file mode 100644
index 0000000..1ec765d
--- /dev/null
+++ b/source/documentation/shex/__index.md
@@ -0,0 +1,86 @@
+---
+title: Apache Jena ShEx
+slug: index
+---
+
+`jena-shex` is an implementation of the 
+[ShEx (Shape Expressions)](https://shex.io) language.
+
+<p>
+<i>This implementation is experimental, starting with Jena 4.2.0.
+Please send usage reports and experience to </i>
+<tt>users@jena.apache.org</tt>.
+</p>
+
+## Status
+
+`jena-shex` reads ShExC (the compact syntax) files.
+
+Not currently supported:
+* semantic actions
+* `EXTERNAL`
+
+Blank node label validation is meaningless in Jena because a blank node label is
+scoped to the file, and not retained after the file has been read.
+
+## Command line
+
+The command `shex` introduces shacl operations; it takes a sub-command
+argument.
+
+To validate:
+
+<pre>shex validate --schema SCHEMA.shex --map MAP.shexmap --data DATA.ttl</pre>
+<pre>shex v -s SCHEMA.shex -m MAp.shexmap -d data.ttl</pre>
+
+To parse a file:
+
+<pre>shex parse <i>FILE</i></pre>
+<pre>shex p <i>FILE</i></pre>
+
+which writes out the parser results in a text format.
+
+<!--
+<pre>shex p <i>--out=FMT</i> <i>FILE</i></pre>
+writes out in `text`(`t`), `compact`(`c`), `rdf`(`r`) formats. Multiple formats
+can be given, separated by "," and format `all` outputs all 3 formats.
+-->
+
+## API
+
+The package `org.apache.jena.shex` has the main classes.
+
+* `Shex` for reading ShEx related formats.
+* `ShexValidation` for validation.
+
+## API Examples
+
+Examples:
+
+https://github.com/apache/jena/tree/main/jena-shex/src/main/java/org/apache/jena/shex/examples/
+
+```
+    public static void main(String ...args) {
+        String SHAPES     = "examples/schema.shex";
+        String SHAPES_MAP = "examples/shape-map.shexmap";
+        String DATA       = "examples/data.ttl";
+
+        System.out.println("Read data");
+        Graph dataGraph = RDFDataMgr.loadGraph(DATA);
+
+        System.out.println("Read schema");
+        ShexSchema shapes = Shex.readSchema(SHAPES);
+
+        // Shapes map.
+        System.out.println("Read shapes map");
+        ShexMap shapeMap = Shex.readShapeMap(SHAPES_MAP);
+
+        // ShexReport
+        System.out.println("Validate");
+        ShexReport report = ShexValidator.get().validate(dataGraph, shapes, shapeMap);
+
+        System.out.println();
+        // Print report.
+        ShexLib.printReport(report);
+    }
+```
diff --git a/source/documentation/tools/__index.md b/source/documentation/tools/__index.md
index 4ff759d..a75caf6 100644
--- a/source/documentation/tools/__index.md
+++ b/source/documentation/tools/__index.md
@@ -129,6 +129,10 @@ pages describe these further.
 file that conforms to the W3C [SHACL](https://www.w3.org/TR/shacl/) standard. 
 Jena's [SHACL](https://jena.apache.org/documentation/shacl/) page has more on this utility.
 
+- **`shex`**: validate data using [ShEx](https://shex.io/) from the
+[W3C Shape Expressions Community Group](https://www.w3.org/community/shex/).
+Jena's [ShEx](https://jena.apache.org/documentation/shex/) page has more on this utility.
+
 - **`rdfdiff`**: compare the triples in two datasets, regardless of their serializations, and list 
 which are different between the two datasets. (Modeled on the UNIX `diff` utility.)