I've got an XSD which has been supplied by a third party and I've then converted this into classes using xsd.exe
.
Due to the fact we do not own this XSD, I'm trying to not alter the generated classes in any way.
Without manually applying a blank string check to every single field we are mapping, e.g.:
!String.IsNullOrWhiteSpace(field) ? field : null;
I can't think of an easy way to serialise the blank strings in a way which means they are not output at all (no tag is produced).
The reason we cannot output blank strings is because the XSD has pattern constraints such as StringM50m1
which I believe means a minimum length of 1 is required (however, they are happy to not receive the tag if there is no content) which fail post-output validation with the following message:
The
'field'
element is invalid - The value''
is invalid according to its datatype'StringM50m1'
- The Pattern constraint failed.
Any thoughts would be appreciated.