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

some shapes use unanchored patterns #25

Open
VladimirAlexiev opened this issue Jul 24, 2024 · 1 comment
Open

some shapes use unanchored patterns #25

VladimirAlexiev opened this issue Jul 24, 2024 · 1 comment

Comments

@VladimirAlexiev
Copy link
Contributor

VladimirAlexiev commented Jul 24, 2024

(Related to #21)

Some ERA shapes use sh:pattern with an unanchored regex, eg "foo". But:

https://w3c.github.io/data-shapes/shacl/#PatternConstraintComponent refers to
https://www.w3.org/TR/sparql11-query/#func-regex which refers to
https://www.w3.org/TR/xpath-functions/#func-matches which says

Unless the metacharacters ^ and $ are used as anchors, the string is considered to match the pattern if any substring matches the pattern.

You can check the same at https://shacl.org/playground/

This means an unanchored pattern doesn't check the whole string. So you always want to use an anchored regex like "^foo$".

Count of such problems from search in github:

  • RINF-sidings-sparql.ttl: 4 unanchored (one is commented out), 3 anchored
  • RINF-contact-line-systems-sparql.ttl: 3 unanchored

I guess that public/doc/era-shapes.ttl is a concatenation of all individual shape files. Here's a grep of such problems in that file, which confirms the number 4+3:

grep -n 'sh:pattern' era-shapes.ttl |grep -Pv '"\^.*?\$"'
130:    sh:pattern "[1-9]\\d{0,5}|0" ;
146:    sh:pattern "[1-9]\\d{0,3}|0" ;
162:    sh:pattern "[1-9]\\d{0,2}|0" ; #TODO check pattern, it is defined as double
1714:   sh:pattern "([1-9]\\d{3}|[1-9]\\d{2}|[1-9]\\d{1}|[0-9])" ;
1732:   sh:pattern "([1-9]\\d{1}|[0-9])\\.[0-9]" ;
1749:   #sh:pattern "([1-9]\\d{2}|[1-9]\\d{1}|[0-9])" ;
1896:   sh:pattern "([1-9]\\d{2}|[1-9]\\d{1}|[0-9])" ;
@ednaru
Copy link
Collaborator

ednaru commented Jul 24, 2024

Thanks. We will add these indications to the ticket already created for issue #21

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

2 participants