XML Bulk upload Processing Question

  • I have multiple XML documents generated from a third party application. I want to use XML Bulk Load to upload the data in the XML document into sql database and indeed I have created the necessary stored procedure to do so.

    The procedure works fine, but the upload fails when the XML file contains records where an element tag is not just 'empty', but missing. The missing element/tag is consistently the same element. Which is:

    XML Validation: Invalid content. Expected element(s): 'FileNo'. Found: element 'DateOfFirstEmployement' instead. Location: /*:ClsContributor[1]/*:ContributorsNew[1]/*:ContributorNew[3]/*:DateOfFirstEmployement[1].

    Basically, the 3rd party application fails to generate the specified element tag for some records within the same xml file.

    How can I use XML Bulk Load to load or ignore and continue processing the xml file?

    Is this something I can correct within the xml schema collection creation script or in the stored proc? :ermm:

  • Try modifying the schema and setting "minOccurs" attribute of the element to "0" to indicate that the element is optional. That might help.

    .

  • jacob sebastian (9/2/2009)


    Try modifying the schema and setting "minOccurs" attribute of the element to "0" to indicate that the element is optional. That might help.

    I wonder why I didn't think of that. You were right! Should have been my initial diagnosis of the problem. Your suggestion put me on track to resolving other problems encountered with the schema.

    Virtual tankard of beer to you.

    Cheers!

  • Glad to know it helped. If you are coming for PASS 2009 summit, do let me know and you can grab a copy of my XSD book 🙂

    .

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply