Shape Expressions Visitor and schema index generator.
npm install @shexjs/visitor


`` shell`
npm install --save @shexjs/visitor
sh
node -e 'console.log(JSON.stringify(new (require("@shexjs/visitor"))()
.visitSchema(
{
"type": "Schema",
"shapes": [
{
"id": "http://a.example/S1",
"type": "Shape",
"expression": {
"type": "TripleConstraint",
"predicate": "http://a.example/p1",
"valueExpr": {
"type": "NodeConstraint",
"values": [
{
"value": "1",
"type": "http://www.w3.org/2001/XMLSchema#integer"
},
{
"value": "2",
"type": "http://www.w3.org/2001/XMLSchema#integer"
}
]
}
}
}
]
}), null, 2))'
`
The result is will look identical to the input schemaStrategy
The ShExJ format is defined in JSG or Typescript. The visitor API reflects both the names of the ShExJ attributes and their types. For example, by default, the visitShapeAnd calls visitShapeExpr on each of the conjuncts. Likewise, visitTripleConstraint calls visitValueExpr on the .valueExpr attribute, which in turn calles visitShapeExpr because that is the type of .valueExpr.Methods
* visitSchema(schema, ...args
* visitPrefixes(prefixes, ...args
* visitIRI(i, ...args
* visitImports(imports, ...args
* visitStartActs(startActs, ...args
* visitSemActs([semActs], ...args
* visitSemAct(semAct, label, ...args
* visitAnnotations([annotations], ...args
* TODO visitAnnotation(annotation, ...args
* visitShapes(shapes, ...args
* visitShapeDecl(decl, ...args
* visitShapeExpr(expr, ...args - calls one of the following
* visitShapeOr(shapeExpr, ...args
* visitShapeAnd(shapeExpr, ...args
* visitShapeNot(expr, ...args
* visitShapeRef(reference, ...args
* visitShapeExternal(expr, ...args
* visitNodeConstraint(shape, ...args
* visitShape(shape, ...args
* visitExtra([extra], ...args
* visitExpression(expr, ...args - calls visitTripleExpr
* visitTripleExpr(expr, ...args - calls one of the following
* visitOneOf(tripleExpr, ...args
* visitEachOf(tripleExpr, ...args
* visitTripleConstraint(expr, ...args
* visitValueExpr(shapeExpr, ...args
* visitValues(values, ...args
* visitValueExpr(shapeExpr, ...args
* visitStemRange(t, ...args
* visitExclusion(c, ...args
* visitInclusion(inclusion, ...args
$3
* visitBase
* visitStart
* visitClosed
* "visit@context"
* visitInverse
* visitPredicate
* visitName
* visitId
* visitCode
* visitMin
* visitMax
* visitType
* visitNodeKind
* visitDatatype
* visitPattern
* visitFlags
* visitLength
* visitMinlength
* visitMaxlength
* visitMininclusive
* visitMinexclusive
* visitMaxinclusive
* visitMaxexclusive
* visitTotaldigits
* visitFractiondigits
* visitIncludeindex(schema)
The
index function creates a visitor and overrides visitExpression and visitShapeExpr to provide an index composed of two maps:
* shapeExprs - map from shape declaration name to definition in schema,
* tripleExprs - map from triple expression name to definition in schema.Lerna Monorepo
This repo uses lerna to manage multiple NPM packages. These packages are located in
packages/*:shape-map -- a ShapeMap parser
- @shexjs/parser -- parse ShExC into ShExJ
- @shexjs/writer -- serialize ShExK as ShExC
- @shexjs/term -- RDF terms uses in ShEx
- @shexjs/util -- some utilities for transforming schemas or validation output
- @shexjs/visitor -- a visitor for schemas
- @shexjs/validator -- validate nodes in an RDF graph against shapes in a schema
- @shexjs/eval-validator-api -- API called by @shexjs/validator for validating Shapes, with tripleExpressions and EXTENDS etc.
- @shexjs/eval-simple-1err -- Implementation of @shexjs/eval-validator-api which reports only one error.
- @shexjs/eval-threaded-nerr -- Implementation of @shexjs/eval-validator-api which exhaustively enumerate combinations of ways the data fails to satisfy a shape's expression.
- @shexjs/loader -- an API for loading and using ShEx schemas
- @shexjs/node -- additional API functionality for a node environment
- @shexjs/cli -- a set of command line tools for transformaing and validating with schemas
- @shexjs/webapp -- the shex-simple WEBApp
- @shexjs/shape-path-query -- traverse ShEx schemas with a path language
- @shexjs/extension-test -- a small language for testing semantic actions in ShEx implementations (more)
- @shexjs/extension-map -- an extension for transforming data from one schema to another (more)
- @shexjs/extension-eval` -- simple extension which evaluates Javascript semantic action code (more)