Java/JAXB: Unmarshall XML attributes to specific Java object attributes

Viewed 29442

There's ugly XML file that has to be unmarshalled:

<?xml version="1.0" ?>
<configuration>
    <section name="default_options">
        <value name="default_port">8081</value>
        <value name="log_level">WARNING</value>
    </section>
    <section name="custom_options">
        <value name="memory">64M</value>
        <value name="compatibility">yes</value>
    </section>
</configuration>

Resulting Java Objects should be:

public class DefaultOptions {
    private int defaultPort;
    private String logLevel;
    // etc...
}

public class CustomOptions {
    private String memory;
    private String compatibility;
    // etc...
}

This question's answer is very close but I can't figure out the final solution.

2 Answers
Related