Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What sort of problems yield validation warnings when parsing a XML document using a XSD schema

Tags:

c#

xml

xsd

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?

like image 507
Robbie Dee Avatar asked Nov 29 '25 14:11

Robbie Dee


1 Answers

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.

like image 158
kjhughes Avatar answered Dec 02 '25 04:12

kjhughes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!