Reputation: 575
I have an xsd, this is part of it:
<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>
I need to validate the shapeId from an xml. The shapeId is a string which can contain letters and numbers, for example this:
shapeId="5dad54ae0c0ba639c4a5a800"
However the pattern that I use validates correctly the shapeId in regextester.com, this xsd throws the exception that 'The shapeId attribute is invalid - The value in invalid according its datatype String.' What I am missing here?
Upvotes: 0
Views: 131
Reputation: 338208
The pattern must match entirely. Your's only matches a single letter. You're missing a quantifier like *
or +
or {24}
:
<xs:pattern value="[a-zA-Z0-9]+" />
Upvotes: 1