I have elements in my xml schema that are of type string. I need to restrict the string, however, to disallow any whitespace at the beginning, end, or "inside" the string and also have a length of at least 1.
Here are some values followed by what I would expect the validation to result in:
"HELLO" (Valid)
"H" (Valid)
"" (Not Valid) [length = 0]
" HELLO" (Not Valid) [starts with space]
"HELLO " (Not Valid) [ends with space]
"HEL LO" (Not Valid) [contains a space]
I know how to make a simple type which restricts string and I know how to require the length to be at least 1:
<xs:simpleType name="MyString">
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
</xs:restriction>
</xs:simpleType>
Now I just need a pattern to add to my simple type that does what I need.
Can someone tell me what pattern to use?
Thank you.
NOTE - I am not using a program like Xml Spy to validate my Xml documents. I am writing a C# program that serializes/deserializes Xml documents using XmlSerializer.
The reason why I bring this up is because I have read various other posts about Xml schema and white spaces and using xs:whiteSpace = preserve, collapse, replace. I don't think that XmlSerializer handles this though.