Internationalising Regular Expressions

This question arises, in part, out of thinking how XForms may handle derived 
datatypes. As the likely audience of English language based Web sites widens, 
capturing and validating text data entered in forms, including XForms, 
becomes a little more complex.

XForms uses the W3C XML Schema <xsd:pattern> element to provide derivation by 
restriction.

Suppose, in English, we want to limit characters to "word characters" we 
might write something like,
<xsd:pattern value="[A-Za-z0-9_]" />

In JavaScript, for example, I might write [A-Za-z0-9_]  more succinctly as 
\w.

However, if I understand Appendix F.1.1 of W3C XML Schema Part 2 the \w 
metacharacter now covers Unicode [#x0000-#x10FFFF]-[\p{P}\p{Z}\p{C}].

So, <xsd:pattern value="\w" /> would match many (unwanted) characters that <
xsd:pattern value="[A-Za-z0-9_] /> would reject as non-matching. Correct?

A couple of other questions arising from this tentative understanding.

In W3C XML Schema, and therefore in XForms, is it correct that the only way 
to express the notion of an English language / ASCII "word character" in a 
regular expression is using [A-Za-z0-9_]? Or, in other words, is there a 
metacharacter which corresponds to the JavaScript use of \w?

Is there any facility to express the notion of, for example, a French word 
character? Or German? Or is the \p{Basic_Latin} the smallest / most precise 
"chunk" of characters that can be used in such a setting?

Andrew Watt

Received on Wednesday, 30 October 2002 05:30:19 UTC