XML Validation From Flat File?

H

Homer

Hi All,

I am trying to convert some Flat Files (Fixed-Width and CSV) to XML
files (Using Java) and I was wondering what is the best way to validate
the data in conversion time (in term and data type, size, missing
fields, etc.)? I know javax.xml.validation helps but is this the
easiest way? Is there any UI tool to help generating these Schema
files?


Thanks in Advance,

Homer
 
O

Oliver Wong

Homer said:
Hi All,

I am trying to convert some Flat Files (Fixed-Width and CSV) to XML
files (Using Java) and I was wondering what is the best way to validate
the data in conversion time (in term and data type, size, missing
fields, etc.)? I know javax.xml.validation helps but is this the
easiest way? Is there any UI tool to help generating these Schema
files?

If I understand your question correctly, wouldn't it make sense to
validate the data when you parse the flat file and are loading its semantic
representation into memory? As for how to validate it, that depends entire
on your data and what you consider valid. For example the technique to
validate a field which must a contain prime number is vastly different from
the technique to validate a field which must contain a date of birth of a
person who is still alive today, for example.

I don't think you can programmatically generate schema files which
specifying what is or isn't valid in some way. And it's probably unrealistic
to just write out your specifications for valid data in plain English and
have an AI read that description and generate XSDs for you. Your best bet is
probably to get a good XML editor which has support for writing XSDs and
write them out yourself.

- Oliver
 
H

Homer

Thanks Oliver for your reply. I did some readings and found one way
(though I am not sure it's easies one). I convert one sample file to
XML (I am using Stylus Studio to do that). Then I run Trang to generate
XSD file from my XML file. From now I can use that XSD to validate all
my files with the same format.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top