Version 1

    Sequence defines the order in which elements (and/or groups of elements) can appear in XML.

    In XSD, this is expressed with xsd:sequence element which contains the list of allowed particles.

    When Java type is bound to a schema type, by default, the schema type will contain a sequence of elements to which the properties of the Java type will be bound. The order of the elements in a sequence can be specified with JAXB annotations, e.g. @XmlType.propOrder and @XmlAccessorOrder.

    If the order of elements is not specified then the properties will be bound in undefined order, which means that the order of elements in the resulting sequence is also undefined.

     

    Why is this important? The order of elements in XML must match the order of elements in the schema. Otherwise, the XML will be considered invalid and parsing (unmarshalling) will fail. If during binding property order was not specified then there is no way of knowing for sure how the schema looks like (there is no even a guarantee that the order in which properties are bound will be consistent after programm restart or a change of the JVM) and so there is a good chance the XML parsing will fail. Therefore, if you bind Java types to sequences, you must specify the order in which properties should be bound.

     

    Starting from version 2.0.1.CR2, XB will throw a runtime exception if there is an attempt to bind to sequence without specifing the property order since it's likely a binding mistake. You can configure XB to ignore this situation and proceed with binding by

    - setting system property xb.builder.sequencesRequirePropOrder to false

    - or by calling org.jboss.xb.builder.JBossXBBuilder.setSequencesRequirePropOrder(false).

     

    Note, XB is configured to bind to unordered sequences (i.e. xb.builder.useUnorderedSequence=true) then it will also not require the property order information since in this mode the order is not important anyway.