users@jaxb.java.net

Re: Order of marshalling items in a collection in JAXB 2.1

From: Nigel Kerr <nigel.kerr_at_gmail.com>
Date: Fri, 4 Dec 2009 07:01:00 -0500

This may be as strong a reed as there is in the current spec, then. I
would advocate strengthening this aspect, possibly:

All collection types are list or array types expressly, not just bags
or sets, unless otherwise specified

or even just something on what exactly happens to the collections at
marshalling time, regardless of what the type is ("All arrays are
consulted from index zero sequentially, all Collection types are
iterated by their default iterators").

Thank much.

On Fri, Dec 4, 2009 at 3:32 AM, Wolfgang Laun <wolfgang.laun_at_gmail.com> wrote:
> It seems that you have discovered an omission in the spec. Although,
> from the Java point of view, not all iterable collections have a specific
> order, in the sense that the same Java program will, or is bound to,
> produce the same order on different JVMs.
>
> A quote from the spec:
> "If the ordering between the children elements is significant and must be
> accessible to the Java application, then the ordering is naturally
> preserved in Java representation via a collection."
>
> I interpret this to hold for both directions, i.e., whenever the Java
> collection type implies a portable order of its elements then this
> will be the order of the marshalled XML elements.
>
> -W