Skip to main content

validate_xml_pattern_syntax

Function validate_xml_pattern_syntax 

Source
pub fn validate_xml_pattern_syntax(pattern: &str) -> Result<(), String>
Expand description

Validate XSD 1.0 regex character-class hyphen rules — stricter than the backend parsers and stricter than XSD 1.1.

Per XSD 1.0 Datatypes §F (regex grammar productions [14]–[22]) under longest-match disambiguation, an unescaped - inside a character class must be (a) the first atom (immediately after [ or [^), (b) the last atom (immediately before ]), (c) the middle character of an seRange (e.g. a-z), or (d) the subtraction operator separating a posCharGroup from a nested charClassExpr (...-[...]). Any other position — e.g. [a-c-1], [^a-d-b-c], [a-z-+], [--z] — is ambiguous and a syntax error in XSD 1.0. XSD 1.1 (Datatypes 1.1 §G) relaxed these rules, allowing literal hyphens elsewhere via XmlCharIncDash, so this validator must only be invoked for XSD 1.0.