Question
· May 19, 2017

XML Import validation to not return on the first error

Hi,

I have an XML file with many repeating elements to validate.

The structure of the file looks like this:

<cm_file>
  <header>
    <sequence_no>919230983</sequence_no>
    <file_date>165362597</file_date>
  </header>
  <payment>
    <client>871619361</client>
    <client_reference>F8718</client_reference>
    <collection_ref>A3302</collection_ref>
    <account_no>N4764</account_no>
  </payment>
  <disbursement>
    <client>83957000</client>
    <client_reference>H36</client_reference>
    <payment_ref>B6426</payment_ref>
    <account_no>M9347</account_no>
  </disbursement>
  <disbursement>
    <client>424960097</client>
    <client_reference>P917</client_reference>
    <payment_ref>L5985</payment_ref>
    <account_no>Z9922</account_no>
  </disbursement>
  <payment>
    <client>333218062</client>
    <client_reference>Z5705</client_reference>
    <collection_ref>O8663</collection_ref>
    <account_no>G8808</account_no>
  </payment>
  <disbursement>
    <client>256341043</client>
    <client_reference>C8259</client_reference>
    <payment_ref>L3084</payment_ref>
    <account_no>Z1235</account_no>
  </disbursement>
  <disbursement>
    <client>defg</client>
    <client_reference>G1475</client_reference>
    <payment_ref>L6061</payment_ref>
    <account_no>Z4998</account_no>
  </disbursement>
  <payment>
    <client>341711590</client>
    <client_reference>F7989</client_reference>
    <collection_ref>H4485</collection_ref>
    <account_no>H6838</account_no>
  </payment>
  <disbursement>
    <client>322528289</client>
    <client_reference>Q4493</client_reference>
    <payment_ref>C833</payment_ref>
    <account_no>M9159</account_no>
  </disbursement>
  <payment>
    <client>abcd</client>
    <client_reference>H2100</client_reference>
    <collection_ref>I3646</collection_ref>
    <account_no>W6040</account_no>
  </payment>
  <disbursement>
    <client>781304097</client>
    <client_reference>O9923</client_reference>
    <payment_ref>C6443</payment_ref>
    <account_no>B9348</account_no>
  </disbursement>
  <payment>
    <client>106031757</client>
    <client_reference>Z9925</client_reference>
    <collection_ref>V4706</collection_ref>
    <account_no>T2154</account_no>
  </payment>
  <disbursement>
    <client>abcd</client>
    <client_reference>Y5439</client_reference>
    <payment_ref>V5209</payment_ref>
    <account_no>I1289</account_no>
  </disbursement>
  <trailer>
    <no_of_records>998924189</no_of_records>
    <file_total>2370.55</file_total>
  </trailer>
</cm_file>

The classes are structured to handle this and if the file is correct, everything is parsed and saved correctly.

What I need is the XML Reader to not abort the parsing and return on the first field validation failure. I need it to parse the file completely, load the entries which were successful, and provide me with a list of errors. Is there a standard way of doing this using %XML.Reader and the SAX parser?

Thanks.

Discussion (3)0
Log in or sign up to continue