user797257
user797257

Reputation:

RELAX NG Compact Syntax regular expression support?

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.

Upvotes: 4

Views: 2225

Answers (1)

Rintze Zelle
Rintze Zelle

Reputation: 1744

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)" }

Upvotes: 5

Related Questions