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

时间:2022-12-15 17:18:40

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验证器在哪里可以找到致命的“当前选项设置”?

1 个解决方案

#1


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.

W3C指定的XML Schema正则表达式风格不支持\ b。错误消息意味着您无论如何都可以通过更改设置来使用它,但之后您将使用非标准功能,这将破坏使用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.

我不确定这是错误信息的真正含义,但如果只有正则表达式无效,它会更有帮助。帮自己一个忙,忘了在你的XSD中使用\ b。如果你还没有,请查看其他的regular-expressions.info网站 - 这是一个很好的资源。

#1


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.

W3C指定的XML Schema正则表达式风格不支持\ b。错误消息意味着您无论如何都可以通过更改设置来使用它,但之后您将使用非标准功能,这将破坏使用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.

我不确定这是错误信息的真正含义,但如果只有正则表达式无效,它会更有帮助。帮自己一个忙,忘了在你的XSD中使用\ b。如果你还没有,请查看其他的regular-expressions.info网站 - 这是一个很好的资源。