Title: Using OGNL instead of field in binding

I am using JiBX for a mapping from an object model to XML (oneway, for now) where there is a growing impedance mismatch, ie: where the structure of the object model does not closely match the structure of the required XML (over which I have no control). So far we have managed to augment our object model with additional getters or front some objects with proxies that present a mutated version of a part of the model.

This is working OK for now but is polluting the object model with much non-business related stuff and this is going to get worse as we have more updates coming for our project that will cause a further divergence between the XML and the model.

I could handle the problem by proxying the whole model with a new interface that more closely resembles the XML schema and binding from from that but that seems like a lot of coding work that I don't think should be necessary. I think that if I have a tool to transform from a model to XML then it should be able to handle the mismatch between the two without requiring changes to either the XML schema or to the object model.

I have been using OGNL for a while for writing testcases where I can compare a value retrieved from an XML document (using XPath) with a value retrieved from the object model. A set of test cases ends up being a text file containing pairs of expressions, one XPath, one OGNL. This makes the addition of even quite complex  transformation test cases relativly easy.

It occurred to me that it should be possible to add some additional access method to the JiBX binding definitions, something like 'ognlexpr', 'get-ognlexpr', 'set-ognlexpr' and 'test-ognlexpr' with functionality similar to 'field', 'get-method', 'set-method' and 'test-method'. Ognl expressions can be written so that they could be used similar to a field name (read and write).

An additional useful feature would an enhancement to the OGNL _expression_ to allow navigation to a parent object as I have often found myself at a point in the binding where I need the value of an attribute to be inserted into the XML where that value comes from a parent or grandparent object of the current object (where a parent is the object you navigated to the current object from).

I was wondering if anyone has done any work integrating OGNL with JiBX or has had more than a cursory think about the idea?

Brian Wallis
Senior Consultant
Object Consulting

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
jibx-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jibx-users

Reply via email to