Schema validation that does not trim lines before validation

I had a problem checking my XML file after it was automatically formatted. Validation does not cut the string before validation. Is this a bug in the implementation of XML.NET validation, or is this an accepted behavior? If the behavior is accepted, such cases are usually handled, since, in my opinion, both XML files are equivalent.

My XSD:

<xs:schema ...> ... <xs:simpleType name="ItemTypeData"> <xs:restriction base="xs:string"> <xs:enumeration value="ItemA" /> </xs:restriction> </xs:simpleType> </xs:schema> 

My XML before formatting (passing validation):

 ... <ItemType>ItemA</ItemType> ... 

After formatting (verification fails):

 ... <ItemType> ItemA </ItemType> ... 
+6
source share
1 answer

Your validator behaves correctly, given the way the circuit is defined. You need to either stop formatting that takes such freedoms with content, or you need to change the scheme - for example, by creating an ItemTypeData restriction of xs: token, not xs: string (in xs: token, leading and trailing spaces are negligible).

+3
source

Source: https://habr.com/ru/post/901014/


All Articles