2

I am trying to reacquaint myself with XML documents and schemas (XSD), but I am having trouble understanding what sort of XML document issues would yield a XmlSeverityType.Warning.

Taking this as an example, what would I need to change in the XML document (or XSD schema) to force a warning to appear?

Robbie Dee
  • 1,939
  • 16
  • 43
  • 1
    Documentation more or less describes that: https://msdn.microsoft.com/en-us/library/system.xml.schema.xmlseveritytype(v=vs.110).aspx – Evk Apr 24 '18 at 10:14
  • @Evk Yes, I saw that. It is a given that it would cover non-error conditions so I didn't find the information provided particularly fruitful. – Robbie Dee Apr 24 '18 at 10:24

1 Answers1

1

As @Evk commented, the documentation for XmlSeverityType.Warning states:

Warning Indicates that a validation event occurred that is not an error. A warning is typically issued when there is no DTD, or XML Schema to validate a particular element or attribute against. Unlike errors, warnings do not throw an exception if there is no validation event handler.

Therefore, it's not so much what to change in your XML or XSD but what you might change to cause your XSD not to be found for your XML, i.e. perturbing (or deleting) the following line in your source:

settings.Schemas.Add("http://www.contoso.com/books", "contosoBooks.xsd");

It's possible that the .NET XSD processor has opted to present additional diagnostics beyond those required by the W3C XSD Recommendation or W3C XML Recommendation (see also valid vs well-formed), but the only change mentioned in the documentation pertains to validation request that cannot be fulfilled due to a missing schema.

kjhughes
  • 106,133
  • 27
  • 181
  • 240