Validating XML using XSD with regex pattern
Asked Answered
T

1

6

I am parsing a XML file against a XSD containing some regex patterns used for checking input data, but only this regex generates an error, even if it passes into the Eclipse XSD plugin:

   InvalidRegex: Pattern value 
   '(((com|org)\.)+(\b[a-z]+[.]{1}\b)+)?[A-Z]{1}[A-Za-z]+' 
   is not a valid regular expression. The reported error was: 
   'This expression is not supported in the current option setting.'.

So even if the problem is caused by the \b boundary which I can safely remove, with SAX validator where can I find the fatal "current option setting"?

Tecumseh answered 10/4, 2010 at 15:50 Comment(3)
Where is your XML so we can see the context in which that restriction is generating an error?Fuchs
Note that {1} can be omitted.Unpaid
Tnx for fixing the reduntant {1}. Currently it is not anymore a problem because I solved when I noticed that removing the "\b...\b" it works without errors. But now I am curious to know where can I set the mentioned "option setting", it could be useful to know where to manipulate these hidden settings.Tecumseh
C
2

\b is not supported by the XML Schema regex flavor as specified by the W3C. The error message implies that you can use it anyway by changing a setting, but then you would be using a non-standard feature, which would defeat the purpose of using XML.

I'm not sure that's what the error message really means, but it would have been more helpful if it had just the regex was invalid. Do yourself a favor and forget about using \b in your XSD's. And check out the rest of the regular-expressions.info site if you haven't already--it's a great resource.

Cressi answered 11/4, 2010 at 3:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.