- From: Steven Pemberton <steven.pemberton@cwi.nl>
- Date: Mon, 12 Feb 2007 14:00:38 +0100
- To: www-xml-schema-comments@w3.org, cmsmcq@acm.org, "CARCHESIO GIOVANNI" <Giovanni.carchesio@bancaditalia.it>
- Message-ID: <op.tnmzrcemsmjzpq@acer3010.wlan.cwi.nl>
(Excuse me for butting in, but I just happened to see your message). > > I'm currently working on XML schemas to be used for a financial > > application. > > There is a specific requirement aiming to provide a data type where: > > > > 1) all strings must be length at least 1 and at most 35; > > 2) the sequence "//" is not allowed within the first 16 characters > > of each string; > > 3) the sequence "//" is allowed within the substring [17..35] of > > each string. > Thank you; this is an interesting problem in the construction of > regular expressions. The language you describe is clearly regular, > but conventional regular expressions, including those of XML Schema, > are a little awkward in handling it, and the regular expression is > likely to be rather complex. > It is, by contrast, easy to state with assertions of the kind > supported by Schematron, or by XML Schema 1.1, and if simplicity of > expression is your primary goal, you may wish to say > <assert test="not(contains(substring(.,1,16),'//'))"/> > <assert test="length(.) > 0"/> > <assert test="length(.) < 36"/> > and be done with it. Can I also point out another W3C technology that allows you to do it: XForms. XForms is already widely used for financial applications. You can say <bind nodeset="t" constraint="string-length(.) > 0 and string-length(.) < 36 and not(contains(substring(.,1,16),'//'))" /> I've attached a complete file that tries this one case. It runs on Firefox with the XForms extension. One thing I noticed while testing is that the rules miss out a case (since it states both valid and invalid states, it leaves a state undefined): what happens when substring(., 16, 17) = "//"? Best wishes, Steven Pemberton
Attachments
- application/xhtml+xml attachment: validity.xhtml
Received on Monday, 12 February 2007 13:00:41 UTC