ShExjava

An implementation of the Shape Expressions Language (ShEx) for rdf validation in java.

License

License

GroupId

GroupId

fr.inria.lille.shexjava
ArtifactId

ArtifactId

shexjava-core
Last Version

Last Version

1.3beta
Release Date

Release Date

Type

Type

jar
Description

Description

ShExjava
An implementation of the Shape Expressions Language (ShEx) for rdf validation in java.
Project URL

Project URL

http://shexjava.lille.inria.fr/
Source Code Management

Source Code Management

https://github.com/iovka/shex-java/tree/master

Download shexjava-core

How to add to project

<!-- https://jarcasting.com/artifacts/fr.inria.lille.shexjava/shexjava-core/ -->
<dependency>
    <groupId>fr.inria.lille.shexjava</groupId>
    <artifactId>shexjava-core</artifactId>
    <version>1.3beta</version>
</dependency>
// https://jarcasting.com/artifacts/fr.inria.lille.shexjava/shexjava-core/
implementation 'fr.inria.lille.shexjava:shexjava-core:1.3beta'
// https://jarcasting.com/artifacts/fr.inria.lille.shexjava/shexjava-core/
implementation ("fr.inria.lille.shexjava:shexjava-core:1.3beta")
'fr.inria.lille.shexjava:shexjava-core:jar:1.3beta'
<dependency org="fr.inria.lille.shexjava" name="shexjava-core" rev="1.3beta">
  <artifact name="shexjava-core" type="jar" />
</dependency>
@Grapes(
@Grab(group='fr.inria.lille.shexjava', module='shexjava-core', version='1.3beta')
)
libraryDependencies += "fr.inria.lille.shexjava" % "shexjava-core" % "1.3beta"
[fr.inria.lille.shexjava/shexjava-core "1.3beta"]

Dependencies

compile (15)

Group / Artifact Type Version
org.apache.commons : commons-rdf-api jar 0.5.0
org.apache.commons : commons-text jar 1.6
org.apache.commons : commons-rdf-rdf4j jar 0.5.0
org.apache.commons : commons-rdf-jena jar 0.5.0
org.eclipse.rdf4j : rdf4j-runtime jar 2.2.2
org.apache.commons : commons-rdf-simple jar 0.5.0
org.jgrapht : jgrapht pom 1.1.0
org.jgrapht : jgrapht-core jar 1.1.0
javax.json : javax.json-api jar 1.1
commons-io : commons-io jar 2.5
com.github.jsonld-java : jsonld-java jar 0.11.1
net.sf.saxon : Saxon-HE jar 9.8.0-7
org.antlr : antlr4-runtime jar 4.7.1
xerces : xercesImpl jar 2.11.0
com.moz.kiji.annotations : annotations jar 3.0.0

test (8)

Group / Artifact Type Version
org.apache.jena : jena-tdb jar 3.11.0
org.apache.jena : jena-arq jar 3.11.0
org.apache.jena : apache-jena-libs pom 3.11.0
org.apache.jena : jena-core jar 3.11.0
org.junit.jupiter : junit-jupiter-engine jar 5.0.0
junit : junit jar 4.12
org.junit.platform : junit-platform-runner jar 1.0.0
org.junit.vintage : junit-vintage-engine jar 4.12.0

Project Modules

There are no modules declared in this project.

Shex-java

Support of Shape Expression Language 2.0 (http://shex.io/shex-semantics/index.html) and validation.

The validation algorithms implemented are the one that appears in:

@inproceedings{boneva:hal-01590350,
  TITLE = {{Semantics and Validation of Shapes Schemas for RDF}},
  AUTHOR = {Boneva, Iovka and Labra Gayo, Jose G and Prud 'hommeaux, Eric G},
  URL = {https://hal.archives-ouvertes.fr/hal-01590350},
  BOOKTITLE = {{ISWC2017 - 16th International semantic web conference}},
  ADDRESS = {Vienna, Austria},
  YEAR = {2017},
  MONTH = Oct,
  PDF = {https://hal.archives-ouvertes.fr/hal-01590350/file/paper-lncs.pdf},
  HAL_ID = {hal-01590350},
  HAL_VERSION = {v1},
}

Install

Maven

You just have to put in the pom.xml file of your project:

<dependency>
  	<groupId>fr.inria.lille.shexjava</groupId>
  	<artifactId>shexjava-core</artifactId>
  	<version>1.0</version>
 </dependency>

Build the jar

With all the tests:

git clone https://github.com/iovka/shex-java.git
git clone https://github.com/shexSpec/shexTest
cd shex-java/shex #cd shex-java\shex for windows user
mvn clean package

Without the tests:

git clone https://github.com/iovka/shex-java.git
cd shex-java/shex #cd shex-java\shex for windows user
mvn clean package

After that, the jar file can be found in the target directory.

Quick guide to update to version 1.1 from 1.0

What is broken and requires some changes

The api now uses commonsRDF (https://commons.apache.org/proper/commons-rdf/) as the core api and this allows for support for Jena, OWL, Apache Clerezza, JSONLD-Java.

The api works with a factory that implements the RDF interface of the commonsRDF api. This factory is the field RDFFactory of the class fr.inria.lille.shexjava.GlobalFactory. By default it is an RDF4J factory but can be change to Jena to something else. All the functions of the api that need to create RDF objects will use the GlobalFactory or the one passed in arguments if you want to use different factories.

Code example to set the factory:

org.apache.commons.rdf.rdf4j.RDF4J factory = new org.apache.commons.rdf.rdf4j.RDF4J();
GlobalFactory.RDFFactory = factory;

The import org.eclipse.rdf4j.model.IRI; need to change import org.apache.commons.rdf.api.IRI;. Same for Literal or BlankNode.

Remove all imports to class of the package fr.inria.lille.shexjava.graph. The graph class used is now org.apache.commons.rdf.api.Graph.

Code example to create the graph:

Graph dataGraph = factory.asGraph(data);

A complete small code example can be found in https://github.com/jdusart/DatatypesShExJava

What is new

The matching found beetween the triple constraints and the RDF triple can now be access using the MatchingCollector of the ValidationAlgorithm. You can remove this functionality by removing them.

Similarly, a FailureAnalyzer can be add to the ValidationAlgorithm to try to find the reason of the failure and store the report.

Code example:

validation.addFailureReportsCollector(new FailureAnalyzerSimple());

A new algorithm for validation as been introduced: RecursiveValidationWithMemorization.

shexTest

To test the package, the shexTest suite must be in the same directories as shex-java.

On validation, the current implementation, using RDF4J, passes 1033 tests, fails 3 tests and skips 41 tests. The tests that are skipped are the one with at least one of those traits:

  • Start
  • SemanticAction
  • ExternalShape
  • ShapeMap
  • Greedy
  • relativeIRI

Using Jena, more tests are failed because new label are generated for bnode (test with trait LexicalBnode). The same mechanism is also present in RDF4J, but has been disabled for the tests.

On negative structure, the current implementation passes all the tests.

On negative syntax, the current implementation passes 100 out of the 102 tests.

Command line example to run the tests and create the report for shexTest:

 > mvn exec:java -Dexec.classpathScope=test -Dexec.mainClass="fr.inria.lille.shexjava.shexTest.CreateTestReport" -Dexec.args="http://example.fr/~me"

Usage

Online validator

You have an online validator available at http://shexjava.lille.inria.fr/ with predefined examples.

Command line validation

With execution through maven

Command line example to run a validation:

>  mvn exec:java -Dexec.classpathScope=test -Dexec.mainClass="fr.inria.lille.shexjava.commandLine.Validate" -Dexec.args="-s  ../../shexTest/schemas/1dotSemi.shex -d file:///home/jdusart/Documents/Shex/workspace/shexTest/validation/Is1_Ip1_Io1.ttl -l http://a.example/S1 -f http://a.example/s1 -a recursive" 

With execution without maven

mvn package
mvn dependency:build-classpath -Dmdep.includeScope=runtime -Dmdep.outputFile=cp.txt
SHEXCP="target/shexjava-core-1.1.jar:"`cat cp.txt`
java -cp $SHEXCP fr.inria.lille.shexjava.commandLine.Validate -s ../../shexTest/schemas/1dotSemi.shex -d https://raw.githubusercontent.com/shexSpec/shexTest/master/validation/Is1_Ip1_Io1.ttl   -l http://a.example/S1 -f http://a.example/s1 -a recursive

Code Exemple

You can find two small projects that use the implementation:

Versions

Version
1.3beta
1.3alpha
1.2.3c
1.2.3b
1.2.3
1.2.2e
1.2.2d
1.2.2c
1.2.2b
1.2.2a
1.2.2
1.2.1
1.2
1.1b
1.1a
1.0