我有以下文件:
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:值'2'对于类型'#AnonType_e'对于模式'[0-9]'而言不是方面有效的。
我在做什么错?
您可以更改模式以允许周围的空白,或者可以添加空白小平面(=“ collapse”)来强制在应用模式之前将空白忽略。