This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi, I need to parse a fixed length text file and then do the data validation on it. File can contain 100+ records. Data validation for each record will typically have: 1) Numeric check, min/max value check, decimal precision check etc. 2) Date check 3) currency code is same in all the amount fields in the record. 4) couple of fields will be validated from the database too...
File level validation: 1)sequence number are in order in the file for each record. 2)seq of record should be header, data --- data , trailer... then again header, data... data, trailer and then finally end.
Whenever there is an error in a field for a record i need to store the error message for the field... and then finally display all the errors for each field in each record rendering an html page.
XML Schema is not for validating data, but XML file format, maybe a little data. Your data is not even in a XML file!!!
You probably don't want to use a hammer to sew your jacket.
Your data file is text, why do you not just write a simple text processing code to validate your data, nice and easy, since you know your text file format!
If you are starting to write your own code, you will quickly find out it is not as hard as you thought. [ July 16, 2007: Message edited by: Roseanne Zhang ]
Joined: May 30, 2007
I think i asked the question in a wrong way.
Actually i want to validate the data while parsing the file. If you look at the articles what its doing is: Storing the constraints in an XSD and reading the XSD to validate the input text. Constraints many be min-max values, allowed values, max length etc. Everything is done in Java.
I will definitely write the code but i was not eager to hard-code those type of values.
I was not sure why the author of the article is using XSD and not XML to configure those things...
Please bear with me as I am very new to these things..
Thanks and regards, Karan
Joined: Nov 14, 2000
Storing the constraints in an XSD and reading the XSD to validate the input text. Constraints many be min-max values, allowed values, max length etc. Everything is done in Java.
XSD validation has nothing to do with "Everything is done in Java." They are not the same thing. Java is a general purpose language, of course, it can do almost anything or everything, but XSD is not.
However, I think that we have discussed your "fixed length text file " enough, from XSLT to XSD. I will quit on this issue. Sorry! [ July 16, 2007: Message edited by: Roseanne Zhang ]
Joined: Nov 14, 2000
Here is a link to the previous discussion related to XSLT, just in case others are curious.