cvc-pattern-valid:值 'A' 对于类型 'whatever' 的模式 '^[A-Za-z]?$' 不是方面有效的 [英] cvc-pattern-valid: Value 'A' is not facet-valid with respect to pattern '^[A-Za-z]?$' for type 'whatever'

查看:64
本文介绍了cvc-pattern-valid:值 'A' 对于类型 'whatever' 的模式 '^[A-Za-z]?$' 不是方面有效的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是验证失败的特定 XML 标记:

Here's the particular XML tag whose validation is failing:

<MiddleName>A</MiddleName>

该标签的 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>

我得到的错误:

cvc-pattern-valid: Value 'A' is not facet-valid with respect to pattern '^[A-Za-z]?$' for type 'MiddleInitial'.

我正在使用的验证器:

http://tools.decisionsoft.com/schemaValidate/

正则表达式看起来不错.^ 匹配开头、$、结尾、?是字母 A-Z 或 a-z 的零或一倍.

The regular expression looks good. ^ matches the start, $, the end, ? is for zero or one times the letters A-Z or a-z.

有什么想法吗?

推荐答案

来自 w3 规范 正则表达式(附录D):

...表达式与整个词法表示匹配而不是用户范围的词法表示,例如 line 和段落.为此,表达式语言不包含元字符 ^ 和 $,虽然 ^ 用于表示异常,例如[^0-9]x

...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, e.g. [^0-9]x

即取出^$.

这篇关于cvc-pattern-valid:值 'A' 对于类型 'whatever' 的模式 '^[A-Za-z]?$' 不是方面有效的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆