以下是验证失败的特定
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'.
我使用的验证器
http://tools.decisionsoft.com/schemaValidate/
正则表达式看起来不错. ^匹配开始,$,结束,?是字母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
即拿出^和$.