Hello,
I'm using JiBX (1.2.2) as part of an existing system to read in custom xml documents to an object model, do something to the objects, then write them back out to xml. Pretty standard stuff and it's been working fine for a long time now. But now I have a request to make a change so that if a specific value attribute is not of the correct for the value type--can't be deserialized to the target type-the String for that value should instead be written to an 'invalid' field in the object and the value set to null. I think this requirement comes about because the number one reason why a document is not read in to our system when we receive them is because of something/someone creating the document without running it through a validator and then JiBX throwing an error because somewhere a Double value is "123xyz". Our system can potentially read in thousands of documents in a batch and isolating a single one at the xml level or going back to the originator and asking them to fix a specific document and sending back just that one is very difficult and causes lots of frustration. So instead of failing, we want to still read in the document while putting the invalid value in a convenient location, creating an error, and then routing the Object to someplace where the problem can be brought to attention and corrected with little fuss. At first I was thinking I could just change the IUnmarshaller implementation we already have in place but I found that ours samples a couple attributes to create Instances of the appropriate type for the Elements being read in and then passes the object back to JiBX to unmarshal. I suspect that JiBX re-reads in the attributes sampled to create the object instance which is probably not be what I want-I can't find anything in the javadoc that says if a read in attribute is only read once or can be read in multiple times. I'm not sure if I could extend the class to read in all the attributes and child elements in order to get what I want. Next, I found out that for the jibx <value> tag there is an optional 'deserializer' attribute that can be defined with the name of a method that takes in a string and returns an Object of the specific type. This sounds great, exactly what I need. But then I find out that the deserializer method has to be static which means I can't set the value of 'invalid' on the specific object instance. Bummer. Can anyone point me at a better solution or give me tips to help me solve my problem? I really liked the second solution and would love it if I could get rid of the static modifier somehow. I think I've thought up a third possible solution where I would actually do only very little changes to JiBX. My idea is to define a new getter and setter for the value that takes and returns a String and tell the binding definition file to use that. I'm pretty sure I can get this to work but I don't like the fact that I lose the actual type in the binding definition and I'm hoping there might be a better solution. Thanks, RONALD KINION | Software Engineer Phone: 425.452.0630 ext 514 | Fax: 425.452.0626 2600 116th Avenue NE, Ste 200, Bellevue, WA 98004 www.edifecs.com <http://www.edifecs.com/> | ronald.kin...@edifecs.com <mailto:ronald.kin...@edifecs.com> 100 Fastest Growing Companies in WA state (Puget Sound Business Journal) Washington's 100 Best Companies to Work For (Seattle Business Magazine) 5000 Fastest Growing Companies in U.S. (Inc. Magazine) CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review; use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender immediately by replying to this e-mail and destroy all copies of the original message. P Please consider the use of resources before printing this e-mail.
<<image001.png>>
------------------------------------------------------------------------------ EditLive Enterprise is the world's most technically advanced content authoring tool. Experience the power of Track Changes, Inline Image Editing and ensure content is compliant with Accessibility Checking. http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users