开发者

Validating XML using XSD with regex pattern

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 开发者_如何学Gointo 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"?


\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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜