• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

data validation using XSD

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

What can be the a good approach to attack this problem?
I came across an article but very old.
http://www.javaworld.com/javaworld/jw-09-2000/jw-0908-validation.html
http://www.javaworld.com/javaworld/jw-10-2000/jw-1013-validation2.html
http://www.javaworld.com/javaworld/jw-11-2000/jw-1110-validation3.html
http://www.javaworld.com/javaworld/jw-12-2000/jw-1208-validation4.html?page=1

I am not sure whether that validation method still good. I am not allowed to use open source utilities.

Is there a way so that i create an XSD and then validate a XML and capture all the errors and not just to check whether the XML is valid or not. I need field level error capturing.

Any help is appreciated.

Thanks and regards,
Karan
[ July 16, 2007: Message edited by: Karan Jain ]
 
Marshal
Posts: 28291
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Most of the four validation points you have there can't be done via XML Schema, even if you did have XML as your input. So that doesn't sound like a promising approach to me.
 
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Paul is correct.

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 ]
 
Karan Jain
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 ]
 
Roseanne Zhang
Ranch Hand
Posts: 1953
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a link to the previous discussion related to XSLT, just in case others are curious.

https://coderanch.com/t/129260/XML/Creating-XML-fixed-length-text

Thanks!
 
What's gotten into you? Could it be this tiny ad?
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic