xml – cvc-pattern-valid:值’A’对于模式’^ [A-Za-z]?$’,对于类型“无论如何”

前端之家收集整理的这篇文章主要介绍了xml – cvc-pattern-valid:值’A’对于模式’^ [A-Za-z]?$’,对于类型“无论如何”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
以下是验证失败的特定 XML标签
<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'.

我使用的验证器

@L_301_1@

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

有任何想法吗?

从w3规格 Regular Expressions (Appendix 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,
e.g. [^0-9]x

即拿出^和$.

原文链接:https://www.f2er.com/xml/292748.html

猜你在找的XML相关文章