-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error with your playground example: MaxCountConstraintComponent #118
Comments
One additional observation. If I reduce the conditions from 2 to 1 in the example it works ( |
Thank you for getting in touch about this. I was able to replicate your issue You were right about blank nodes. Internally, the shapes graph is combined with the SHACL triples themselves and this is where blank nodes get mixed up. It is a common problem with RDF/JS stack, which has no easy solution. The easiest possible fix of your snippet would be to ensure the parsing happens using the same factory you later pass to the SHACL Engine async function loadDataset(filePath) {
const { factory, ParserN3 } = await importDependencies()
const stream = fs.createReadStream(filePath)
+ const parser = new ParserN3()
+ const parser = new ParserN3({ factory })
return factory.dataset().import(parser.import(stream))
} Otherwise, I might suggest to simplify this code significantly by using the RDF Environment. You could keep import SHACLValidator from 'rdf-validate-shacl'
import factory from '@zazuko/env-node'
async function run() {
// use factory to parse
const shapes = await factory.dataset().import(factory.fromFile("shapes.ttl"))
const data = await factory.dataset().import(factory.fromFile("data.ttl"))
console.log(await shapes.serialize({ format: 'text/n3' }))
const validator = new SHACLValidator(shapes, { factory })
const report = await validator.validate(data)
console.log(await report.dataset.serialize({ format: 'text/n3' }))
}
run()
|
Great, thanks a lot @tpluscode! Your suggestion indeed makes it work 👍 |
I am getting
Error: Cannot find validator for constraint component http://www.w3.org/ns/shacl#MaxCountConstraintComponent
when running your playground example:This is my
script.js
:And this is my
package.json
:I run it like this:
node script.js
.👉 However, if I rewrite the SHACL shapes to not include blank nodes, it works:
That makes me think that you might have an internal bug regarding blank nodes? Or am I doing something wrong? 🤔
The text was updated successfully, but these errors were encountered: