users@jaxb.java.net

Unmarshalling 'enum's

From: Luc <useyour.mind_at_gmail.com>
Date: Fri, 17 Aug 2012 10:15:46 +0200

Hello!

I'm using JAXB to marshal/unmarshal objects, and some of them are
enumobjects and lists of that
enum elements.
But when unmarshalling a list of enum, there can't be any new line in the
XML. In example:

public enum Numbers {
> ONE, TWO, THREE
> }
> private static class EnumList {
> private ArrayList<Numbers> array = new ArrayList<Numbers>();
> public EnumList() {}
> public void setArray(ArrayList<Numbers> array) {
> this.array = array;
> }
> public ArrayList<Numbers> getArray() {
> return array;
> }
> }


When unmarshalling an XML like this:

<?xml version="1.0" encoding="UTF-8"?>
> <EnumList>
> <list>ONE</list>
> <list>TWO</list>
> <list>THREE</list>
> </EnumList>


Works great, but if the third element has a new line before or after its
name, JAXB returns a null:

<?xml version="1.0" encoding="UTF-8"?>
> <EnumList>
> <list>ONE</list>
> <list>TWO</list>
> <list>

 THREE</list>
>
<!-- or
> <list>THREE
> </list>
> -->

</EnumList>


Is this the expected behaviour?
Thanks,
--
Lucas