title: JAXB Unmarshal - Elements missing and elements in not in order
body: <p>I am trying to unmarshal an XML that I marshalled before.</p>
  
  <p>In the unmarshalled result, I am missing elements and the elements I get are not in the same order as the input XML. I've created a afterUnmarshal() listener and I see the elements there, but not in the resulting Java Object.</p>
  
  <p>The XSD is structured like this (a 'fanout'-node, for example, can contain another set of processSteps, so it can be deeply nested (tree)):</p>
  
  <pre><code>&lt;xsd:element name="process"&gt;
          &lt;xsd:annotation&gt;
              &lt;xsd:documentation&gt;Integration Process&lt;/xsd:documentation&gt;
          &lt;/xsd:annotation&gt;
          &lt;xsd:complexType&gt;
              &lt;xsd:sequence&gt;
          &lt;!-- more --&gt;
                  &lt;xsd:element name="itinerary" type="lwis:itineraryType"/&gt;
          &lt;!-- more --&gt;
          &lt;/xsd:complexType&gt;
      &lt;/xsd:element&gt;
      &lt;xsd:complexType name="itineraryType"&gt;
          &lt;xsd:sequence&gt;
              &lt;xsd:element name="step" type="lwis:stepType"/&gt;
              &lt;xsd:choice minOccurs="0" maxOccurs="unbounded"&gt;
                  &lt;xsd:element name="step" type="lwis:stepType"/&gt;
                  &lt;xsd:element name="fanout" type="lwis:fanoutType"/&gt;
                  &lt;xsd:element name="decision"&gt;
                      &lt;xsd:complexType&gt;
                              &lt;!-- snip.. --&gt;
                      &lt;/xsd:complexType&gt;
                  &lt;/xsd:element&gt;
              &lt;/xsd:choice&gt;
          &lt;/xsd:sequence&gt;
      &lt;/xsd:complexType&gt;
  </code></pre>
  
  <p>I suppose the order is given by the SAX parser, but I can't imagine a SAX parser would change the order for no reason? At the moment, the first element in the list is the last one in the XML. The second element in the list is the third in the XML - it seems random..</p>
  
  <p>Thanks for any help!</p>
  
  <p>Sample Input:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?&gt;
  &lt;process name="My.Process" description="My Process description" qualityOfService="AT_LEAST_ONCE" entryEndpoint="ENTRY.EP" xmlns="http://www.xxxxx.com/ns/yyyy"&gt;
      &lt;faultEndpoint endpoint_ref="EXIT.EP"/&gt;
      &lt;rejectEndpoint endpoint_ref="EXIT.EP"/&gt;
      &lt;itinerary&gt;
          &lt;step name="Step 1" endpoint_ref="Step1.EP" type="SERVICE"/&gt;
          &lt;step name="Step2-CBRStep" endpoint_ref="Step2.EP" type="SERVICE"/&gt;
          &lt;decision name="Decision-nonameneeded"&gt;
              &lt;option name="op1"&gt;
                  &lt;step name="Step 2A" endpoint_ref="Step2a.EP" type="SERVICE"/&gt;
              &lt;/option&gt;
              &lt;option name="op2"&gt;
                  &lt;step name="Step 2B" endpoint_ref="Step2a.EP" type="SERVICE"/&gt;
              &lt;/option&gt;
          &lt;/decision&gt;
          &lt;step name="Step 3" endpoint_ref="Step3.EP" type="SERVICE"/&gt;
          &lt;fanout name="Fan1"&gt;
              &lt;path&gt;
                  &lt;step name="Step4A" endpoint_ref="Step4A.EP" type="SERVICE"/&gt;
              &lt;/path&gt;
              &lt;path&gt;
                  &lt;step name="Step4B" endpoint_ref="Step4B.EP" type="SERVICE"/&gt;
                  &lt;step name="Step5" endpoint_ref="Step5.EP" type="SERVICE"/&gt;
              &lt;/path&gt;
          &lt;/fanout&gt;
          &lt;step name="Step6" endpoint_ref="Step6.EP" type="SERVICE"/&gt;
      &lt;/itinerary&gt;
  &lt;/process&gt;
  </code></pre>
  
  <p>Object:</p>
  
  <pre><code>Process Object has a field with itinerary of Type ItineraryType which:
  step = StepType ("Step6" from XML)
  stepOrFanoutOrDecision = ArrayList:
   item 0: ItineraryType$Decision ("Decision-nonameneeded" from XML)
     option 0: "op1" from XML
       step: "Step 2A" from XML
     option 1: "op2" from XML
       step: "Step 2B" from XML
   item 1: FanoutType ("Fan1" from XML)
       path 0: 
        step: Step4A
       path 1: 
        step: Step5
  </code></pre>
  
  <p>Step 1, Step2-CBRStep and Step 4B is missing?</p>
  
  <p>I have the toString() output of the itinerary here:</p>
  
  <pre><code>com.x.ItineraryType@fe39ebf[step=com.x.StepType@28cb15bf[endpointRef=Step6.EP, type=SERVICE, params=&lt;null&gt;, paramsRef=&lt;null&gt;, name=Step6, description=&lt;null&gt;], stepOrFanoutOrDecision={com.x.ItineraryType$Decision@2d00c385[option={com.x.ItineraryType$Decision$Option@d2467d8[step=com.x.StepType@511d9ca5[endpointRef=Step2a.EP, type=SERVICE, params=&lt;null&gt;, paramsRef=&lt;null&gt;, name=Step 2A, description=&lt;null&gt;], stepOrFanoutOrDecision=&lt;null&gt;, name=op1],com.x.ItineraryType$Decision$Option@6f173e3d[step=com.x.StepType@5ef74fc5[endpointRef=Step2a.EP, type=SERVICE, params=&lt;null&gt;, paramsRef=&lt;null&gt;, name=Step 2B, description=&lt;null&gt;], stepOrFanoutOrDecision=&lt;null&gt;, name=op2]}, name=Decision-nonameneeded, description=&lt;null&gt;],com.x.FanoutType@3e963f38[path={com.x.FanoutType$Path@7a1095a1[step=com.x.StepType@56cfbba2[endpointRef=Step4A.EP, type=SERVICE, params=&lt;null&gt;, paramsRef=&lt;null&gt;, name=Step4A, description=&lt;null&gt;], stepOrFanoutOrDecision=&lt;null&gt;, name=&lt;null&gt;],com.x.FanoutType$Path@6027b534[step=com.x.StepType@4ee99a3d[endpointRef=Step5.EP, type=SERVICE, params=&lt;null&gt;, paramsRef=&lt;null&gt;, name=Step5, description=&lt;null&gt;], stepOrFanoutOrDecision=&lt;null&gt;, name=&lt;null&gt;]}, name=Fan1, description=&lt;null&gt;]}]
  </code></pre>
  
  <p>Ant Script I'm using: with extensions hashCode, toString and equals:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project name="RunningXjc" default="generate-sources" basedir="."&gt;
      &lt;description&gt;Runs Xjc Binding Compiler&lt;/description&gt;
  
      &lt;target name="generate-sources"&gt;
          &lt;taskdef name="xjc" classname="org.jvnet.jaxb2_commons.xjc.XJC2Task"&gt;
              &lt;classpath&gt;
                  &lt;fileset dir="buildLib/jaxb-ri-2.2.6/lib"&gt;
                      &lt;include name="*" /&gt;
                  &lt;/fileset&gt;
                  &lt;fileset dir="buildLib/jaxb2-basics-dist-0.6.4/dist"&gt;
                      &lt;include name="jaxb2-basics-ant-*.jar" /&gt;
                  &lt;/fileset&gt;
              &lt;/classpath&gt;
          &lt;/taskdef&gt;
  
          &lt;!-- Generate the Java code for XSD --&gt;
          &lt;xjc destdir="${basedir}/target/generated-sources/xjc" extension="true"&gt;
              &lt;arg
                  line="
          -Xequals
          -XhashCode
          -XtoString
          -Xcopyable
          -Xmergeable" /&gt;
              &lt;binding dir="${basedir}/src"&gt;
                  &lt;include name="**/*.xjb" /&gt;
              &lt;/binding&gt;
              &lt;schema dir="${basedir}/schema"&gt;
                  &lt;include name="processSlim.xsd" /&gt;
              &lt;/schema&gt;
              &lt;!-- Plugins --&gt;
              &lt;classpath&gt;
                  &lt;fileset dir="${basedir}/buildLib/jaxb2-basics-dist-0.6.4"&gt;
                      &lt;!-- JAXB2 Basics library --&gt;
                      &lt;include name="dist/jaxb2-basics-*.jar" /&gt;
                      &lt;!-- JAXB2 Basics library dependencies --&gt;
                      &lt;include name="dist/jaxb2-basics-runtime-*.jar" /&gt;
                      &lt;include name="dist/jaxb2-basics-tools-*.jar" /&gt;
                      &lt;include name="lib/commons-beanutils-*.jar" /&gt;
                      &lt;include name="lib/commons-lang-*.jar" /&gt;
                      &lt;include name="lib/commons-logging-*.jar" /&gt;
                      &lt;include name="lib/javaparser-*.jar" /&gt;
                      &lt;include name="lib/annox-*.jar" /&gt;
                  &lt;/fileset&gt;
              &lt;/classpath&gt;
          &lt;/xjc&gt;
      &lt;/target&gt;
  &lt;/project&gt;
  </code></pre>