3

I want to validate one of the required data field which contains a string. data are in a tab delimited file. I have created a simpleType as below,

<xsd:element minOccurs="1" maxOccurs="1" name="Barcode" type="String20"/>

<xsd:simpleType name="String20">
    <xsd:restriction base="xsd:string">
        <xsd:minLength value="1"/>
        <xsd:maxLength value="20"/>
    </xsd:restriction>
</xsd:simpleType>

This validation does not break when the data is empty. I also changed minLength to 2 and tested with one character, but it did not break on that too.

Does any one know how to validate empty string please?

Thanks

Ash
  • 447
  • 2
  • 6
  • 19
  • How are you using XSD to validate a Tab Delimited File? – Alexander Higgins Jul 17 '17 at 06:37
  • Works as expected under .net and xerces – Sprotty Jul 17 '17 at 11:29
  • I'm using XmlReaderSettings() in C#. and use XmlSchemaSet() to set my xsd schema – Ash Jul 18 '17 at 06:11
  • Maybe there is an issue with the validation code. Post the code you use to do the validation – Sprotty Jul 18 '17 at 16:21
  • I had a similar issue and was only able to fix it thanks to feedback from guys here telling me to use an assert. Maybe that is what will help you? https://stackoverflow.com/questions/69195370/how-to-force-a-comlpextype-element-to-have-at-least-3-characters-in-a-string – Daniel Janz Sep 18 '21 at 16:01

0 Answers0