Open chrdebru opened 5 months ago
SHACL can do regex, once the listed regex is tested and test cases are provided with valid and invalid templates, we can add it.
Tasks required:
@DylanVanAssche could you take care of this?
Define a few test-cases with invalid templates. AFAIK, these are the 'rules':
A string template is a format string that can be used to build strings from multiple components. It can apply [reference expressions](https://kg-construct.github.io/rml-core/spec/docs/#dfn-reference-expression) by enclosing them in curly braces ({ and }). The following syntax rules apply to valid [string templates](https://kg-construct.github.io/rml-core/spec/docs/#dfn-string-template):
1. Pairs of unescaped curly braces MUST enclose valid [reference expressions](https://kg-construct.github.io/rml-core/spec/docs/#dfn-reference-expression).
2. Curly braces that do not enclose [reference expressions](https://kg-construct.github.io/rml-core/spec/docs/#dfn-reference-expression) MUST be escaped by a backslash character (\). This also applies to curly braces within [reference expressions](https://kg-construct.github.io/rml-core/spec/docs/#dfn-reference-expression).
3.Backslash characters (\) MUST be escaped by preceding them with another backslash character, yielding (\\). This also applies to backslashes within [reference expressions](https://kg-construct.github.io/rml-core/spec/docs/#dfn-reference-expression).
4.There SHOULD be at least one pair of unescaped curly braces.
from spec.
Anything missing? If not, we need to have 4 invalid test cases, one for each rule.
I don't think so, please proceed :-)
I believe that checking the validity of templates should be included in the shapes. I'm not sure whether SPARQL's regular expressions allow for recursion, but it can be achieved by:
^[^\{\}]*(?:\{[^\{\}]+\}[^\{\}]*)*$
(balanced and not nested)This can be achieved for a SPARQL constraint component.