问题描述
<xs:complexType name="Shape">
<xs:annotation>
<xs:documentation>
Shape object
</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="archimate:ViewNodeType" >
<xs:attribute name="shapeId" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[a-zA-Z0-9]" />
</xs:restriction>
</xs:simpleType>
</xs:attribute>
我需要从xml验证shapeId。 shapeId是可以包含字母和数字的字符串,例如:
shapeId="5dad54ae0c0ba639c4a5a800"
但是,我使用的模式正确验证了regextester.com中的shapeId,此xsd引发了一个例外,即“ shapeId属性无效-根据其数据类型String,该值无效。” 我在这里想念什么?
解决方法
模式必须完全匹配 。您只匹配一个字母。您缺少像*
或+
或{24}
这样的量词:
<xs:pattern value="[a-zA-Z0-9]+" />