It appears that the when creating a document through the Java API, the order of the elements in a sequence in the produced document is the order in which 'set' was called, and not the order defined in the schema (that is, we produce an invalid document!).
This seems like a reasonable bean-based approach, otherwise you need to know the exact schema in order to populate an XML sequence.
Also, it means it's a real pain to modify an existing document by adding an optional element in the middle of a sequence.
Surly the schema provides enough information for the engine to order the sequence elements regardless of the order of calling the 'setter' method.
Are we doing something wrong, or is this just how XMLBeans works?
For example:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Root">
<xs:annotation>
<xs:documentation>Root Element</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:sequence>
<xs:element name="First" type="xs:string">
<xs:annotation>
<xs:documentation>First element in sequence</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="Second" type="xs:string">
<xs:annotation>
<xs:documentation>Second element in sequence</xs:documentation>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
If we call 'setSecond' before 'setFirst' an invalid document is produced.
Thanks,
Ophir
"Beware of the man who works hard to learn something,
learns it, and finds himself no wiser than before. He is full of
murderous resentment of people who are ignorant without having
come by their ignorance the hard way."