【发布时间】:2020-03-03 23:25:48
【问题描述】:
我有以下文件:
a.xml
<?xml version="1.0"?>
<e xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="a.xsd">
2
</e>
a.xsd
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="e">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[0-9]"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:schema>
验证时我得到:
错误:(4, 5) cvc-pattern-valid: Value ' 2 '对于类型'#AnonType_e'的模式'[0-9]'不是构面有效的。
我做错了什么?
【问题讨论】:
标签: xml validation design-patterns xsd restriction