-
Notifications
You must be signed in to change notification settings - Fork 64
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
Specify focus node as cli parameter #53
Comments
Hi @michielhildebrand Specifying a focus node has always been a feature the library can do but I never considered would be something a user would want to do via the CLI, but I can see it might be useful. How do you envisage it working? Would you want to specify a SHACL Shapes graph, a Data Graph, and the URI for a focus node? Something like this? |
Hi, The use case is as follows. I started with a nodeShape with a targetClass: The problem is that in the graph there are more resources of type crm:E22_Human-Made_Object and I only want to test a specific one. I changed it to use a targetNode vgw:Artwork Now this works fine. The problem is that other users of this shapes graph need to change it and add their own URI in the targetNode. Specifying the focusNode in the command line (or library api) makes this more convenient. The complication is that the focusNode is not "bound" to the vgw:Artwork node shape any more. I could put back the "sh:targetClass crm:E22_Human-Made_Object". But then I am back at the problem that this shape will be called for other resources as well. In particular because there are resources related to my focusNode of this type that I also want to test, but then with a sh:node. So it sounds like I need to call it with a focusNode and a nodeShape. Does this make any sense? Or did I miss something? |
Yes I believe I understand what you are saying. And it does bring up an obvious problem with the solution I proposed. That is; when you specify a focusNode to validate, how does the validator know which SHACL shapes to apply? The way PySHACL works internally, is it goes through all of the known SHACL Shapes in the shapes graph, and for each shape it determines which nodes in the DataGraph to apply the shape to. Those are the focus nodes. It cannot go the other way around, there is no mechanism in PySHACL for given a focusNode, find the SHACL Shapes which apply to it. Without that, even your example using I will need to think about this a bit more. Perhaps the solution would be to implement an alternate mode for PySHACL to operate, where it can be given a focusNode and a NodeShape to use, and it does not use the normal PySHACL algorithm at all. |
I understand. Thanks for explaining. We are exploring alternative solutions to define the targets better. I think we will manage in that way. You can park this issue if you like. |
No problems. We'll put this on hold for now, and think about it further down the track. |
Just a note that Cheka allows for this in a round-about way. There you can indicate a node to be validated by including in the data a conformance claim, i.e. node X claims conformance to some profile and the profile lists all the Shapes that are defined for conformance testing to the profile. |
The SHACL recommendation states the following option to define a focus node:
specified as explicit input to the SHACL processor for validating a specific RDF term against a shape
https://www.w3.org/TR/shacl/#focusNodes
It would be great to have this feature.
BTW. Great project! It got me started with SHACL in minutes.
The text was updated successfully, but these errors were encountered: