La validación del esquema no recorta las cadenas antes de validar

I have a problem with validating my XML file, after it has been automatically formatted. The validation doesn't trim the string before validating it. Is this a bug in the implementation of the XML validation of .NET or is this accepted behavior? If it is accepted behavior, how are cases like this normally handled, because in my opinion, the two XML files are equivalent.


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

My XML before formatting (validation passes):


After formatting (validation fails):


preguntado el 08 de noviembre de 11 a las 10:11

1 Respuestas

Your validator is behaving correctly, given the way the schema is defined. You either need to stop the formatter taking such liberties with the content, or you need to change the schema - for example by making ItemTypeData a restriction of xs:token rather than xs:string (in xs:token, leading and trailing whitespace is considered insignificant).

respondido 08 nov., 11:15

Thanks a lot! xs:token is what I was looking for. - Daniel Hilgarth

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.