XML Validation From Flat File?

Discussion in 'Java' started by Homer, May 29, 2006.

  1. Homer

    Homer Guest

    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
    Homer, May 29, 2006
    #1
    1. Advertising

  2. Homer

    Oliver Wong Guest

    "Homer" <> wrote in message
    news:...
    > 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
    Oliver Wong, May 29, 2006
    #2
    1. Advertising

  3. Homer

    Homer Guest

    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.
    Homer, May 29, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. BlackSnail
    Replies:
    1
    Views:
    422
    Christopher Boomer
    Aug 6, 2003
  2. Replies:
    0
    Views:
    571
  3. R. P.
    Replies:
    3
    Views:
    8,242
    Joe Kesselman
    Jun 22, 2006
  4. Rob

    Flat file to XML

    Rob, Apr 6, 2007, in forum: XML
    Replies:
    5
    Views:
    740
    Alain Ketterlin
    Apr 6, 2007
  5. c676228
    Replies:
    3
    Views:
    344
    Mike Brind [MVP]
    Jul 17, 2008
Loading...

Share This Page