Repository navigation
define \w as [^\p{P}\p{Z}\p{C}] in the xsd regex parser - #145
Conversation
|
Why does xmlbeans need to become strict after over 20 years and no-one complaining about it being lax? |
|
Fair point. Nobody has complained because the lax side is quiet. A facet like That said, I agree it shouldn't change under existing users. Pushed c788baa:
I went with a system property, not an |
c788baa to
5a4553e
Compare
…operty
\w and \W in pattern facets now follow the XML Schema definition
([#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}]) by default. The pre-5.5.0 XML 1.0
Letter and Digit tables are available per type system with
XmlOptions.setCompileLegacyRegexWordClass(), replacing the
xmlbean.regex.strictword system property.
The choice is a new "L" regex option, so it is per expression rather than
global. Compiled .xsb files record it with a FLAG_SCHEMA_REGEX_WORD type
flag; types written by older versions lack the flag and load with the
legacy tables, so existing precompiled schema jars keep their behaviour.
Older runtimes ignore the flag, so no xsb version bump is needed.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
5a4553e to
c769a1c
Compare
|
I merged this with an XmlOptions setting. The new behaviour is the default but users can use xmloptions if they need the old behaviour. |
Differential run of one schema and one set of documents through XmlBeans and the JDK's Xerces validator, pattern facet on
xs:string:Found while auditing the pattern facet for values an instance can slip past. The run produced 63 disagreements where XmlBeans accepts and Xerces rejects, and 67 the other way round. Every one of them is on
\w,\Wor[^\w]. The other escapes agree.XML Schema Part 2, Appendix F, defines
\was[#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}]: every character that is not punctuation, a separator or "other".ParserForXMLSchema.getRangebuildsxml:isWordfrom the XML 1.0LetterandDigittables instead. Those are Unicode 2.0 name characters. So symbols (+,^,|,$), combining marks, letter numbers (Ⅷ), titlecase letters (Dž) and letters added after Unicode 2.0 (ſ,ff) sit outside\w. A facet written with\Wor[^\w]accepts them and one written with\wrejects them. Only schema mode (optionX, which is what pattern facets use) is affected. Xerces corrected the same port in 2.12.0 (XERCESJ-1651).The fix mirrors Xerces:
\Wis the union of theP,ZandCcategory tokens the class already has, and\wis its complement.\d,\s,\i,\cand the Perl-mode word class are untouched. With the change the differential run has no remaining\wdisagreement. Regression test added toRegularExpressionTest; it fails before the change and passes after../gradlew testpasses.