简体   繁体   中英

Validate text file (not XML) with XSD?

I need to validate a flat file ( text file ) with an XSD file (schema). I found to do this for a XML file but not for text file.

Is there any base class to do that ?

The contents of the text file is as follows:

Header

SubHeader (many)

Records (many)

Footer

An XSD cannot be used to validate an arbitrary text file, only an XML file.

The validation rules specified in the W3C XML Schema Recommendation are defined against XML elements and attributes , not arbitrary text:

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

[Order rearranged and emphasis added from original source .]

XSD stands for Xml Schema Definition . You can only use it to check xml, not arbitrary text.

Your best bet would be to refresh your Regex skills.

可能你想使用Flat File Checker,是一个用于导入和导出文件中数据验证的开源应用程序,那么这可以帮助你https://www.codeproject.com/Articles/43398/Validating-data-with-Flat -文件检查器

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM