SHAPES-rs
This repo contains an RDF data shapes library implemented in Rust. The implementation supports ShEx, SHACL, DCTap and conversions between different RDF data modeling formalisms.
The code can be used as a Rust library but it also contains a binary called rudof which can be used as an RDF playground.
We provide binaries for Linux, Windows, Mac and Docker (see releases), as well as Python bindings.
Installation
Official releases
You can download a binary from the latest release page. There you will also find the compiled packages for the installation on your system using a package manager.
Ubuntu
Download the binary from [https://github.com/weso/shapes-rs/releases] and install the .deb package running the following commands after replacing X.X.X by the latest version:
Windows
The binary can be downloaded from [https://github.com/weso/shapes-rs/releases]
Mac
The binary is available at: [https://github.com/weso/shapes-rs/releases]
Compiling from source
shapes-rs has been implemented in Rust and is compiled using cargo. The command cargo run can be used to compile and run locally the code.
For example:
Compiling from source and installing the binary (Debian)
Install cargo deb (only the first time)
Create the .deb package by:
And run:
Docker
The library is also published as a Docker image.
Usage
Some examples
The folder examples contains several example files with ShEx schemas and RDF data.
Validate a simple RDF file with a ShEx schema using a ShapeMap
We maintain a Wiki page with some common Usage scenarios and How-to guides.
Debugging information
It is possible to change the debug level information with:
where value can be debug to show more verbose information or info to show basic information.
Command line usage
)
)
Obtaining information about a ShEx schema
Obtaining information about RDF data
Obtaining information about a node in RDF data
This command can be useful to obtain the neighbourhood of a node.
For example, the following command shows the neighbourhood of node wd:Q80 in the Wikidata endpoint.
Validating an RDF node against some data
)>
Example: Assuming there a ShEx file in examples/user.shex and an RDF turtle file in examples/user.ttl we can ask to validate node :a with shape label :User using:
If there is a shapemap in examples/user.sm, we can validate using:
Validating an RDF node against some SHACL Shape
Conversion between shapes formalisms
)>
Main modules
The repo is divided in the following modules:
- iri_s defines simple IRIs.
- srdf simple RDF model which will be used for validation.
- prefixmap Prefix maps implementation.
- shapemap ShapeMap implementation.
- shex_ast defines the ShEx Abstract syntax
- shex_compact contains the code required to handle ShEx compact syntax.
- shex_validation contains the code required to validate RDF using ShEx.
- shex_testsuite contains the code required to run the ShEx testsuite.
- shacl_ast defines the SHACL core Abstract syntax.
- shacl_validation contains the code required to validate RDF using SHACL.
- dctap contains the code required to do handle DCTAP files.
- shapes_converter contains the code required to do conversion between different shapes formalisms.
Publishing the crates
Worskpaces
The project is using cargo workspaces wihch can be installed with:
Unit-testing
In order to test all the sub-projects
Testing one specific subproject:
Using the ShEx test-suite
The ShEx testsuite is included in a git submodule. In order to obtain it, it is necessary to do:
)>
Validation conformance tests for ShEx
Schemas tests
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributors
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.