Skip to content
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

Enable sh:pattern on IRIs #52

Closed
dr-shorthair opened this issue Jun 9, 2020 · 5 comments
Closed

Enable sh:pattern on IRIs #52

dr-shorthair opened this issue Jun 9, 2020 · 5 comments

Comments

@dr-shorthair
Copy link

dr-shorthair commented Jun 9, 2020

It is quite a common requirement to test an IRI to check if it is in a specific namespace, or contains a path element which is a specific character string or pattern. While the SHACL spec appears to restrict application of sh:pattern to string literals, it would be helpful to allow a 'relaxed' mode where it can also apply to IRIs (which are, after all, just a sequence of characters).

Note that the TopBraid SHACL engine (maintained by the SHACL editor @HolgerKnublauch ) does operate in this mode - see https://groups.google.com/forum/?utm_source=digest&utm_medium=email#!topic/topbraid-users/BUoROZt0BhM

@ashleysommer
Copy link
Collaborator

I don't believe there is need for separate 'relaxed' mode for this change. Changing sh:pattern to work on IRIs as well as strings does not cause any of tests in the SHACL test suite to fail.

@dr-shorthair
Copy link
Author

FWIW it looks like the TQ SHACL implementation is here: https://github.com/TopQuadrant/shacl

@HolgerKnublauch
Copy link

The spec is IMHO clear that IRIs can be checked too.

@ashleysommer
Copy link
Collaborator

ashleysommer commented Jun 10, 2020

@HolgerKnublauch
Yes you're right. Re-reading the relevant sections I see it is pretty obvious. I think it was this part which threw me off:

The values of sh:pattern in a shape are literals with datatype xsd:string

I originally read that as "the focusnodes of sh:pattern constraint are literals with datatype xsd:string" so thought it excluded IRIs.

However, just looking at implementing this feature in pySHACL I see it is already implemented. All string-based constraint operations already work on IRIs, and not by accident, there is even a method in there for all string-based constraints to turn an IRI to a string before evaluating. So the spec must've been clear to me back when I wrote that code too.

So can close this as not a bug.

@dr-shorthair
Copy link
Author

@HolgerKnublauch It is explicit on sh:minLength and sh:maxLength with the phrase "This can be applied to any literals and IRIs, but not to blank nodes.". Not explicit on sh:pattern (this briefly threw us off the trail), but not excluded either.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants