Hi Florian,

For your needs as described the handling should be easy - just use an add-method on the Container Object for processing the unmarshalled Data Object instances, and have that call a validation method on each instance it's passed. If the Data Object says it's valid go ahead and process it fully, including the commit. If the object says it's not valid, just stick it on an invalid list. That way at the end you have the whole list of invalid objects for your report.

The above assumes you only need to recover from domain validation errors, rather than structural errors in the XML document being unmarshalled (which result in JiBXExceptions from the generated unmarshalling code). Recoverable structural error handling is planned for JiBX v2, but in v1 there's no easy way to do this automatically. If you need structural error recover you're stuck with using the custom unmarshaller approach. :-( On the bright side, this should be fairly easy to implement as a generalized handler (or even easier as one that's got the name of your Data Object elements hard coded). The handler would only need to process the list of Data Objects (so use normal JiBX marshalling/unmarshalling for any other data in the Container Object). It'd basically just be a loop that unmarshals the child Data Objects one at a time, catching any unmarshalling exception and skipping input until you're back to the tag nesting depth you started with if an error occurs. Now that I think about it, that'd make a nice addition to the custom code examples - maybe I'll try to put it together for 1.1.

 - Dennis

[EMAIL PROTECTED] wrote:

Hello,

I have following problem and no good idea for a solution:

We have a XML file that contains a Container Object and a list of complex
Data Object that must be imported into a database.

For each Data Object a domain validation is required. If the validation
failed the object with the data will be rejected. Data should not be
inserted into the database, -> rollback!
After a reject of a object the next Data Object should be processed. For
each rejected object we must produce a report, so we have at the end a bag
of failed objects or XML references.

We need also for each processed Data Object a commit.

Is this possible with JBIX or must I look for another technology :-(

So my solution in mind is, to implement a own marshaller and unmarshaller
Handler for the container Object  and handle the error processing and
database processing there :-(.
The rest of the mapping operation should be done in the normal way.
All the validation of the data object can I  hopefully implement in the
post-set method.

Or is the solution to implement a own MarshallerContext.

Thanks
Florian




-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to