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

xsd regular expression support for character classes #68

Closed
mgsmith1000 opened this issue Jan 16, 2019 · 3 comments
Closed

xsd regular expression support for character classes #68

mgsmith1000 opened this issue Jan 16, 2019 · 3 comments

Comments

@mgsmith1000
Copy link
Contributor

An rpc with an input parameter that is a string with a pattern "\w[\w_-]*" did not match the value "a-b". After stepping through with gdb, I found that regcomp() fails to compile this expression. The function regexp_xsd2posix() probably needs to replace '\w' with something that is valid in POSIX ERE.

When attempting to replace this with a regex that works with regcomp(), the pattern "[0-9A-Za-z-]" also didn't compile. Moving the '-' to the last character in the bracket expression ('[0-9A-Za-z-]') worked.

@dcornejo
Copy link
Contributor

RFC 7950 sec 9.4.5 references W3 XML Schema Part 2 as the standard for the regular expressions used in the pattern statement: https://www.w3.org/TR/2004/REC-xmlschema-2-20041028/#regexs

olofhagsand added a commit that referenced this issue Jan 17, 2019
  * added support for \c, \d, \w, \W, \s, \S
@olofhagsand
Copy link
Member

Thanks for the reference link.
I added translation for \w, \d, \s, and some others. Please come back if there are other POSIX vs XSD regex mismatches.
However, it would be better if one could reuse an xsd regex check tool. Know of anyone?

@dcornejo
Copy link
Contributor

these guys have a lot of tools I've found useful: https://yangcatalog.org/
(especially the YANG regex validator). If you explore their github, you can find the source for a version of grep (w3cgrep) that is behind their validator. It uses the regex lib from libxml2.

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