XSD Validation - Allowed characters
-
I’m having a problem setting up schema validation using regular expressions - I have been stuck on this for some time and would appreciate some help... I have a set of allowed characters that I could describe using this regular expression:
[\w?\-?.?\s?\'?,?#?-[_]]
This means that I allow any alphanumeric characters and characters like dash, period, spaces, apostrophe, comma, and number (hash) symbol. The last part of the expression tries to exclude underscore since \w allows it, and my application does not like underscores. The problem is that this is an allowed set of characters and I am using the XSD pattern facet so that I can use schema validation to find rogue characters. XSD validation fails when the expression in the pattern facet does not match. My pattern looks like this:
xs:pattern="[\w?\-?.?\s?\'?,?#?-[_]]"
This basically works except that when characters not in range are present, the expression still matches. So if I add an @ or % symbol somewhere in the data, the expression happily matches even though there is invalid data present. I looked at groups, forward, and reverse references, conditionals, etc. I have also tried to match on characters not in the set ( like this:
[^\w?\-?.?\s?\'?,?#?]
), but that does not help since the presence of disallowed characters actually causes the expression to match thereby causing schema validation to pass! The set of allowed characters is much smaller than the set of disallowed characters, so it would not be practical to create an expression having disallowed characters. Any advice?Erik Westermann - wWorkflow.net - (primarily)BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453 -
I’m having a problem setting up schema validation using regular expressions - I have been stuck on this for some time and would appreciate some help... I have a set of allowed characters that I could describe using this regular expression:
[\w?\-?.?\s?\'?,?#?-[_]]
This means that I allow any alphanumeric characters and characters like dash, period, spaces, apostrophe, comma, and number (hash) symbol. The last part of the expression tries to exclude underscore since \w allows it, and my application does not like underscores. The problem is that this is an allowed set of characters and I am using the XSD pattern facet so that I can use schema validation to find rogue characters. XSD validation fails when the expression in the pattern facet does not match. My pattern looks like this:
xs:pattern="[\w?\-?.?\s?\'?,?#?-[_]]"
This basically works except that when characters not in range are present, the expression still matches. So if I add an @ or % symbol somewhere in the data, the expression happily matches even though there is invalid data present. I looked at groups, forward, and reverse references, conditionals, etc. I have also tried to match on characters not in the set ( like this:
[^\w?\-?.?\s?\'?,?#?]
), but that does not help since the presence of disallowed characters actually causes the expression to match thereby causing schema validation to pass! The set of allowed characters is much smaller than the set of disallowed characters, so it would not be practical to create an expression having disallowed characters. Any advice?Erik Westermann - wWorkflow.net - (primarily)BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453Well, in case anyone is interested, I solved my problem. Schema validation turned out to be too limited to handle all cases, so now I use schema validation combined with rules in the BizTalk Rules Engine (this was part of a larger BizTalk-based solution). So, schema validation catches more obvious, structural issues whereas the Business Rules make it easier to validate based on regular expressions, etc.
Erik Westermann - wWorkflow.net - BizTalk Consulting Services
SOA * ESB * BPI * SaaS ... forget the alphabet soup - get the main course with our consulting services!
wWorkflow.net or +1 416-809-1453