我需要使用 XSD 文件(架构)验证平面文件(文本文件)。我发现可以为 XML 文件执行此操作,但不能为文本文件执行此操作。
是否有任何基类可以做到这一点?
文本文件内容如下:
Header
SubHeader (many)
Records (many)
Footer
最佳答案
XSD 不能用于验证任意文本文件,只能用于验证 XML 文件。
validation rules在 W3C XML Schema Recommendation 中指定是defined针对 XML 元素和属性,而不是任意文本:
Throughout this specification, Definition: the word valid and its derivatives are used to refer to [the following:]
[...] whether an element or attribute information item satisfies the constraints embodied in the relevant components of an XML Schema
[从 original source 添加的顺序和强调.]
关于c# - 使用 XSD 验证文本文件(不是 XML)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35311796/