Click here to Skip to main content
15,890,043 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Is there a way to print out user friendly XSD validation error messages?

For example, if a mandatory field is missing then the message should be specific that the mandatory field is indeed missing.

Take the following XML as example where <name> is mandatory but is missing. Fields <birthday> and <contactno> are defined above the <age> field, and are not in the XML as well.

<person>
<age>22
<height>188
<weight>165


I've looked at the ValidationEventArgs event exception details and the information available are the line number which the validation issue was detected and the list of possible elements expected
C++
List of possible elements expected: 'Name, Birthday, ContactNo' in



Is there a way to make is specify that the "Name" field is mandatory and is missing in the XML document?

Thanks in advance
Posted

1 solution

Only by parsing the string and creating your own message from it, I expect.
 
Share this answer
 
Comments
Miggleness 27-Aug-10 0:01am    
However, the string does not specify which of the three fields are mandatory. I'm trying to avoid manual work as much as possible. Is there a more automated way of achieving friendly xml validation messages?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900