C#中用户友好的XSD验证 [英] User Friendly XSD Validation in C#

查看:83
本文介绍了C#中用户友好的XSD验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以打印出用户友好的XSD验证错误消息?

例如,如果缺少必填字段,则该消息应具体说明确实缺少必填字段.

以以下XML为例,其中< name>是必填项,但缺少.字段< birthday>和< contactno>在< age>上方定义字段,并且不在XML中.

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


我查看了ValidationEventArgs事件异常的详细信息,可用的信息是检测到验证问题的行号以及预期的可能元素的列表

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

List of possible elements expected: 'Name, Birthday, ContactNo' in

中的"code-string">' 姓名,生日,联系方式'


有没有一种方法可以指定名称"字段是必填字段,并且在XML文档中缺少该字段?

预先感谢




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

Thanks in advance

推荐答案

我希望只有解析字符串并从中创建您自己的消息.
Only by parsing the string and creating your own message from it, I expect.


这篇关于C#中用户友好的XSD验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆