[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 8.3.4 app:accept schema



* Thomas Broyer wrote:
>This one should exactly match:
>(?P<type>[^\0-\x1f\x7f-\xff()<>@,;:\\\"[\]?={}
>\t]+)/(?P<subtype>[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={}
>\t]+)(?P<params>\s*;\s*(?P<paramName>[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={}
>\t]+)=\"?(?P<paramValue>(?<=\")(?:[^\0-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?(?=\")|(?<!\")[^\0-\x08\x0A-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={}
>\t]+(?!\"))\"?)(*\s*,\s*((?P<type>[^\0-\x1f\x7f-\xff()<>@,;:\\\"[\]?={}
>\t]+)/(?P<subtype>[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={}
>\t]+)(?P<params>\s*;\s*(?P<paramName>[^\0-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={}
>\t]+)=\"?(?P<paramValue>(?<=\")(?:[^\0-\x1f\x7f-\xff\\\"]|\\[\0-\x7f])*?(?=\")|(?<!\")[^\0-\x08\x0A-\x1f\x7f-\xff()<>@,;:\\\"/[\]?={}
>\t]+(?!\"))\"?))*

It does not. For example, you are using \s which matches many more
characters than you mean to match (non-ascii characters, form feeds,
etc., depending on whom you ask). It is also not suiteable for use
in the grammar as it would require to define a PCRE data type library,
and to use XML Schema data types you would have to considerably re-
write it (for example, XML Schema has no support for character re-
ferences, and U+0000 cannot occur literally, so you would have to
compute the intersection of the character classes and the characters
allowed in XML and express them so that the disallowed characters do
not occur).

I think instead of including such patterns, it would be best to
define patterns for the individual types, give them a very lax
grammar, and point out that this is just a rough approximation to
keep the schema simple; for validation and actual processing, the
data types should be redefined, e.g. to use a custom data type library.
Giving a complex but inaccurate pattern here would lead to confusion
and probably also encourage bad practise, like using \s to parse the
value when using regular expressions for the task.
-- 
Björn Höhrmann · mailto:bjoern@xxxxxxxxxxxx · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/