简体   繁体   中英

Flat file schema validation using regular expression - not allow new line and delimiter char

I know this must be primitive question but I am still not able to find a solution to my simple problem.

In a BizTalk solution, I want to validate a inbound flat file against a flat file schema (Delimiter char is pipe '|'). The rule is that there must be exact same number of fields in every record (every line). So after disassembling, none of the field must have new line char (CR LF or \\r\\n) and pipe '|' char.

Every line in flat file is a single record and there are 10 fields in every record. so there must me exact 9 '|' pipe chars in every line.

I tried to solve it using XSD regular expression validation but since regex is not my area of expertise, I am not able to create a final regex. Currently I am testing with .*(?!([^\\r\\n\\|])).* but it doesn't work when there are more than 9 '|' chars however it works when there are less than 9.

Finally I want a XSD regex which must not allow a new line char and '|' in string but can have empty '' value.

I have referred below links to create my regex,

XML Schema Regular Expressions

XML Schema - Regular Expressions

I think you're trying to solve the wrong problem.

First, do you really need to do this? I don't recall ever needing or even considering what you're describing.

Second, you can just Validate the parsed Xml. If the field count is wrong, it will fail there. If you really need to check for extra '|', you can put that in the Schema to test for it in a Map.

IBM Integration Bus solves this problem by allowing you to describe the non-XML data format using an XSD. The technology is called Data Format Description Language (DFDL). https://en.wikipedia.org/wiki/Data_Format_Description_Language

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