[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Internationalising Regular Expressions


xsd pattern w
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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.