NPM module to use shape-path-core to query data.
const N3 = require("n3");
const Sp = require('shape-path-core')
const { ctor: RdfJsDb } = require('@shexjs/neighborhood-rdfjs')
const yy = { // resolution for PNames in ShapePath
base: new URL('http://project.example/schema'),
prefixes: {
'issue': 'http://project.example/ns#'
}
}
const pathStr = '@issue:DiscItem ~ issue:href'
const pathExpr = new Sp.ShapePathParser(yy).parse(pathStr)
console.log(`${pathStr} compiles to ${JSON.stringify(pathExpr)}`)
const filePath = Issue.json
const schema = readJson('Issue.json')
const schemaNodes = pathExpr.evalPathExpr([schema], new EvalContext(schema))
const graph = new N3.Store();
const turtleStr = Fs.readFileSync('Issue2.ttl', 'utf8');
const parser = new N3.Parser({ baseIRI: 'http://a.example/' });
graph.addQuads(parser.parse(turtleStr));
const db = RdfJsDb(graph)
shapePathQuery (schema, nodeSet, db, node, shape)
@types/shexj
evalPathExpr
@shexjs/neighborhood-rdfjs
./bin/spquery.js \
'@<http://project.example/schema#DiscItem>~<http://project.example/ns#href>,@<http://project.example/schema#Issue>~<http://project.example/ns#spec>/valueExpr/shapeExprs~<http://project.example/ns#href>' \
../../node_modules/shape-path-core/examples/issue/Issue.json \
-d ./examples/issue/Issue2.ttl \
-m '<http://instance.example/project1/Issue2>@<http://project.example/schema#Issue>'
or npm run toy
from this directory
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)