简体   繁体   English

使用带有正则表达式模式的XSD验证XML

[英]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 into the Eclipse XSD plugin: 我正在针对包含用于检查输入数据的一些正则表达式模式的XSD解析XML文件,但只有这个正则表达式生成错误,即使它传递到Eclipse XSD插件:

   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边界引起的,使用SAX验证器在哪里可以找到致命的“当前选项设置”?

\\b is not supported by the XML Schema regex flavor as specified by the W3C. W3C 指定XML Schema正则表达式风格不支持\\b 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. 错误消息意味着您无论如何都可以通过更改设置来使用它,但之后您将使用非标准功能,这将无法使用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. 帮自己一个忙,忘了在你的XSD中使用\\b And check out the rest of the regular-expressions.info site if you haven't already--it's a great resource. 如果你还没有,请查看其他的regular-expressions.info网站 - 这是一个很好的资源。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM