When a transformation includes structural changes like aggregation - thus cannot wholly be expressed as item-to-item mapping - XSLT or XQuery may sometimes accomplish very elegantly what would be cumbersome otherwise.
A simple and efficient pattern for transforming A into B can in such cases be, schematically:
Document aXml = a.toXML();
Document bXml = execXSLT(stylesheet, aXml);
B b = new B().fromXML(bXML);
Here is my request, part A:
To support this special case of custom converter explicitly: introduce a "stylesheet" attribute, which is an alternative to the "custom-converter" attribute. And Dozer does the rest. Like:
<field custom-stylesheets="a2b.xslt b2a.xslt" />
Prerequisite: source and target would have to implement a "toXML" and a "fromXML" method (take names just as proposals). So my request, part B:
To introduce a Dozer interface consisting of toXML and fromXML; and/or to introduce attribute names for specifying custom-toXML and custom-fromXML methods:
<field custom-stylesheet="foo.xslt bar.xslt">
<a toXML="dumpXML" fromXML="loadXML">foo</a/>
<b toXML="writeXML" fromXML="readXML">bar</b>
</field>
Thanks.
- Hans-Juergen