Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RELAX NG Compact Syntax regular expression support?

Tags:

regex

xml

relaxng

Is it possible to define a pattern for text in RELAX NG Compact Syntax in the way Regular Expressions are defined, or, maybe even simpler variations of regular grammar which only has "or" and character classes / sequencing operations?

Essentially, I would like to declare an attribute as only allowing values that would otherwise match this regexp: 0x[0-9A-Fa-f]{6}. I could limit it to minLength and maxLength, but I'm not sure if I can define a rule for the characters.


1 Answers

http://books.xmlschemata.org/relaxng/relax-CHP-9.html describes regular expression support in RELAX NG.

An example, in the compact syntax, can be found in https://github.com/citation-style-language/schema/blob/master/csl.rnc :

element cs:issn { issn }
issn = xsd:string { pattern = "\d{4}\-\d{3}(\d|x|X)" }
like image 74
Rintze Zelle Avatar answered Nov 17 '25 10:11

Rintze Zelle



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!