[英]cvc-pattern-valid: Value 'A' is not facet-valid with respect to pattern '^[A-Za-z]?$' for type 'whatever'
Here's the particular XML tag whose validation is failing: 这是验证失败的特定XML标记:
<MiddleName>A</MiddleName>
The XSD for that tag: 该标记的XSD:
<xsd:element name="MiddleName" type="MiddleInitial" />
<xsd:simpleType name="MiddleInitial">
<xsd:restriction base="xsd:string">
<xsd:pattern value="^[A-Za-z]?$" />
</xsd:restriction>
</xsd:simpleType>
The error I'm getting: 我得到的错误:
cvc-pattern-valid: Value 'A' is not facet-valid with respect to pattern '^[A-Za-z]?$' for type 'MiddleInitial'.
The validator I'm using: 我正在使用的验证器:
http://tools.decisionsoft.com/schemaValidate/ http://tools.decisionsoft.com/schemaValidate/
The regular expression looks good. 正则表达式看起来很好。 ^ matches the start, $, the end, ?
^匹配开始,$,结束,? is for zero or one times the letters AZ or az.
是字母AZ或az的零或一倍。
Any ideas? 有任何想法吗?
From the w3 spec Regular Expressions (Appendix D) : 从w3规范正则表达式(附录D) :
...expressions are matched against entire lexical representations rather than user-scoped lexical representations such as line and paragraph.
...表达式与整个词法表示形式匹配,而不是用户范围的词汇表示形式,如行和段落。 For this reason, the expression language does not contain the metacharacters ^ and $, although ^ is used to express exception, eg [^0-9]x
出于这个原因,表达式语言不包含元字符^和$,尽管^用于表示异常,例如[^ 0-9] x
Ie take out the ^
and $
. 即拿出
^
和$
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.