--- tags: ShEx, JVM, API --- # ShEx Validation JVM API Tracking issues: * [iovka/shex-java](https://github.com/iovka/shex-java/issues/27) * [weso/shex-s](https://github.com/weso/shex-s/issues/224) * [Apache Jena](https://issues.apache.org/jira/browse/JENA-2115) Goal: common API for invoking basic validation function across all JVM ShEx validators. The input parameters: 1. ShapeMap or node/shape pair 2. ShEx schema 3. getNeighborhood implementation can be split across multiple operations: 1. construct validator 2. execute validator These can be tuned to optimize for: 1. validate different data with same schema 2. validate data with different schema 2 seems a bit unlikely so propose to aim for 1. That implies passing the schema in with the validator constructor, so it can index the schema for efficient validation. ``` java abstract class Validator { Validator(ShExSchema schema); ResultShapeMap validate(FixedShapeMap pairs, NeighborhoodDB db); } interface NeighborhoodDB { ArrayList<Triple> getNeighborhood(RdfNode); } // https://shexspec.github.io/shape-map/ interface FixedShapeMap { RdfNode node; ShExShape shape; Enum { conformant, nonconformant } status; } interface ResultShapeMap extends FixedShapeMap { string reason; AppInfo appinfo; } abstract class AppInfo {} ``` The shex.js FixedShapeMap can include a status which allows you to signal an error only when you get a different status. Not sure that's great, but it's handy. ## Existing APIs: ### shex-java ### shex-s ### Jena