Reputation: 3849
I am looking for a XML serialization framework which has an option for a XML configuration instead of annotation to name classes and fields.
I looked at Simple and XStream but I didn't find a method to do it. I suppose I could use Spring IOC and XStreams aliasing, but if there's any frameworks, which could do this for me, it would of course be better :)
Upvotes: 3
Views: 1009
Reputation: 67760
I love XStream because it mostly Just WorksTM.
I haven't tried this myself or given it a lot of thought, but have you considered using XStream both for the actual data and its own configuration? I'm thinking you could use XStream to read a configuration file, and then use the (simple String
) data obtained therefrom as the arguments to alias()
method calls prior to processing the data.
Upvotes: 0
Reputation: 149007
EclipseLink JAXB (MOXy) has a externalized binding file based on the JAXB metadata
A sample file looks something like:
<xml-bindings xmlns="http://www.eclipse.org/eclipselink/xsds/persistence/oxm">
<java-types>
<java-type name="org.example.order.PurchaseOrder">
<java-attributes>
<xml-attribute java-attribute="id"/>
<xml-element java-attribute="customer">
<xml-java-type-adapter value="org.example.order.CustomerAdapter"/>
</xml-element>
<xml-element java-attribute="lineItems" name="line-item"/>
</java-attributes>
</java-type>
</java-types>
</xml-bindings>
For more information see: - http://wiki.eclipse.org/EclipseLink/Examples/MOXy/EclipseLink-OXM.XML
Upvotes: 0
Reputation: 57192
JiBX is a Java to XML Binding framework in which you can use XML bindings. The XML is a bit verbose and can sometimes be a little hard to manage, but that can be true of any XML configuration. I know you said you've looked at xstream, but some xstream configuration can be done through code (not configuration, but through configuring the xstream object, for example, omitting fields). I'm not sure if that's enough for you, but you can do some things without the annotations.
Upvotes: 3