There are many ways to transform a been to XML string. My implementation should satisfy these requirements:
- Allow to specify the been attributes(fields) that will be included in output XML string. Attributes names can be specified in any format, for example in XPath or in XSLT.
- Attributes names specifications should allow versioning: sets of attributes will be different for different versions. Then annotations (JAXB style) are not acceptable: for attribute that is not in bean anymore I need to keep information that in previous versions this attribute existed and has been included in XML string.
- Transformation should be fast. This requirement is important considering that the been can have thousands attributes, some of them are other beans, and small subset of fields will be included in output XML string.
- Using 3rd party (for example, FreeMarker) is possible, but ideally just standard JDK should be used.
Example: class A {String a1; String a2; B b}; class B (String b1; String b2}
To specify attributes in output XML here is set of attributes names, specified in XPath-like format:
/A/@a1; /A/b/@b1
Values of attributes: a.a1="value_a1"; a.b.b1="value_b1"
Output XML : <A><a1>value_a1</a1><b><b1>value_b1</b1></b></A>
Would you recommend a tool or approach to implement these requirements?
TIA
No comments:
Post a Comment