views:

196

answers:

3

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 :)

+3  A: 

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.

Jeff Storey
+1 jibx is the only up-to-date marshalling framework I know of that has externalised binding definitions
skaffman
At a first glance, I think that this is exactly what I need.
Trick
A: 

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"&gt;
    <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

Blaise Doughan
A: 

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.

Carl Smotricz