.NET XML validator doesn’t give accurate error message for prohibited attributes
I am creating a validator in .NET8 for railML data format (based on XML) using XDocument.Validate() and XMLSchemaSet, but I encountered a situation when if I place an attribute in an element that, for example, doesn’t allow it or any attributes or doesn’t allow extensions from schemas in that place (doesn’t have xsi:any or xsi:anyAttribute etc) it provides an error message like this: “The ‘nameOfAttribute’ attribute is not declared.“.
In comparison if you place an incorrect child element, this is the kind of message I get: