Help with XSD field pattern.

Hello everyone,

I need to define a pattern for a field in XSD where it is a string datatype. The total length is 11. It must allow any data which starts with “S” or “s” followed by 10 digits. S and s are optional.

If they are not sending S or s infront of the number. It must allow the number. Here is what I got but I dont know whether its true or not. Can someone help.

<xs:element name=“Sample”>
xs:simpleType
<xs:restriction base=“xs:string”>
<xs:pattern value=“[1]?(\d{10})+$”/>
</xs:restriction>
</xs:simpleType>
</xs:element>

Regards,
David.


  1. Ss ↩︎

Hello David,
I never tried doing the field validations in xsd itself(never heard if it can be done that way) but instead if you do it in a branch/sequence step you can use /[1]{1}[1-9]{10}$/ pattern.In your case try using [2]{1}[1-9]{10}$ (with out slashes)

Thank you,
Anil


  1. S|s ↩︎

  2. S|s ↩︎

Thanks Anil for your response.

I have found a link on google,where we can test the pattern and it is correct.

Thanks,