title: JaxB Unmarshall error : java.lang.RuntimeException: unexpected element (uri:"", local:"code"). Expected elements are <{}section>
body: <p>please advise what may be the issue with this JAXB Unmarshall code
  This is the error message I receive when I try to unmarshall the XML I have provided below: </p>
  
  <p><strong>java.lang.RuntimeException: unexpected element (uri:"", local:"code"). Expected elements are &lt;{}section></strong></p>
  
  <p>Borrower class is parsed using JaxB based on the XSD , using JDK 1.7 and Eclipse IDE. </p>
  
  <p>:</p>
  
  <pre><code>public class UnmarshallApplication {
  
  public static void main(String[] args) {
  
  
  
      try {
  
      JAXBContext jaxbContext  = JAXBContext.newInstance(Borrower.class);
      Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
  
      jaxbUnmarshaller.setEventHandler(new ValidationEventHandler() {
                  public boolean handleEvent(ValidationEvent event ) {
                      throw new RuntimeException(event.getMessage(),event.getLinkedException());
                                                                     }
          });
  
  
      StringReader xmlCCR = new StringReader(returnValue2());
      JAXBElement&lt;Borrower&gt; root = jaxbUnmarshaller.unmarshal(new StreamSource(xmlCCR), Borrower.class);
      Borrower productListResponse = root.getValue();
  
  
  
      } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Borrower class :</p>
  
  <pre><code>package bg.rbb.unmarshall;
  import java.util.ArrayList;
  import java.util.List;
  import javax.xml.bind.annotation.XmlAccessType;
  import javax.xml.bind.annotation.XmlAccessorType;
  import javax.xml.bind.annotation.XmlAttribute;
  import javax.xml.bind.annotation.XmlElement;
  import javax.xml.bind.annotation.XmlRootElement;
  import javax.xml.bind.annotation.XmlType;
  
  @XmlAccessorType(XmlAccessType.FIELD)
  @XmlType(name = "", propOrder = {"section"})
  @XmlRootElement(name = "borrower")
  
  public class Borrower {
  
  @XmlElement(required = true)
  protected List&lt;Section&gt; section;
  @XmlAttribute(name = "code", required = true)
  protected String code;
  @XmlAttribute(name = "name")
  protected String name;
  
  public List&lt;Section&gt; getSection() {
      if (section == null) {
          section = new ArrayList&lt;Section&gt;();
      }
      return this.section;
  }
  
  public String getCode() {
      return code;
  }
  
  public void setCode(String value) {
      this.code = value;
  }
  
  
  public String getName() {
      return name;
  }
  
  
  public void setName(String value) {
      this.name = value;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>XSD :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:wmh="http://www.wmhelp.com/2003/eGenerator" 
  elementFormDefault="qualified"&gt;
  &lt;xs:element name="borr-info-list"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="borrower" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="req-file-name" type="xs:string"/&gt;
    &lt;xs:attribute name="req-file-time" type="xs:string"/&gt;
    &lt;xs:attribute name="req-file-user" type="xs:string"/&gt;
    &lt;xs:attribute name="req-file-entity" type="xs:string"/&gt;
    &lt;xs:attribute name="out-file-time" type="xs:string"/&gt;
    &lt;xs:attribute name="borr_count" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="borrower"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="section" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="code" type="xs:string" use="required"/&gt;
    &lt;xs:attribute name="name" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="section"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="active-credits"/&gt;
      &lt;xs:element ref="overdue-history"/&gt;
      &lt;xs:element ref="new-credits"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="entity-type" type="xs:string" use="required"/&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="active-credits"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="summaries" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="cred-count" type="xs:string"/&gt;
    &lt;xs:attribute name="source-entity-count" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="summaries"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="summary" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
    &lt;xs:attribute name="grouping-attribute" type="xs:string" use="required"/&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="summary"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:attribute name="date-from" type="xs:string"/&gt;
    &lt;xs:attribute name="type" type="xs:string"/&gt;
    &lt;xs:attribute name="amount-approved" type="xs:string"/&gt;
    &lt;xs:attribute name="amount-drawn" type="xs:string"/&gt;
    &lt;xs:attribute name="monthly-installment" type="xs:string"/&gt;
    &lt;xs:attribute name="outstanding-performing-principal" type="xs:string"/&gt;
    &lt;xs:attribute name="outstanding-overdue-principal" type="xs:string"/&gt;
    &lt;xs:attribute name="balance-sheet-value" type="xs:string"/&gt;
    &lt;xs:attribute name="off-balance-sheet-value" type="xs:string"/&gt;
    &lt;xs:attribute name="overdue-payment-period" type="xs:string"/&gt;
    &lt;xs:attribute name="rest" type="xs:string"/&gt;
    &lt;xs:attribute name="term" type="xs:string"/&gt;
    &lt;xs:attribute name="active" type="xs:string"/&gt;
    &lt;xs:attribute name="year" type="xs:string"/&gt;
    &lt;xs:attribute name="category" type="xs:string"/&gt;
    &lt;xs:attribute name="months-count" type="xs:string"/&gt;
    &lt;xs:attribute name="max-cred-count" type="xs:string"/&gt;
    &lt;xs:attribute name="max-outstanding-overdue-principal" type="xs:string"/&gt;
    &lt;xs:attribute name="max-outstanding-overdue-interest-and-others" 
    type="xs:string"/&gt;
    &lt;xs:attribute name="max-off-balance-sheet-dues" type="xs:string"/&gt;
    &lt;xs:attribute name="date-last-correction" type="xs:string"/&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="overdue-history"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="summary" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;xs:element name="new-credits"&gt;
  &lt;xs:complexType&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element ref="summary" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  &lt;/xs:schema&gt;
  </code></pre>
  
  <p>XML :</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;borrower&gt;
     &lt;code&gt;7777777777&lt;/code&gt;
     &lt;name&gt;FirstName Surname LastName&lt;/name&gt;
     &lt;section&gt;
        &lt;entity-type&gt;banks&lt;/entity-type&gt;
        &lt;active-credits&gt;
           &lt;cred-count&gt;2&lt;/cred-count&gt;
           &lt;source-entity-count&gt;1&lt;/source-entity-count&gt;
           &lt;summaries&gt;
              &lt;grouping-attribute&gt;type&lt;/grouping-attribute&gt;
              &lt;summary&gt;
                 &lt;date-from&gt;2017-12-31&lt;/date-from&gt;
                 &lt;type&gt;Card&lt;/type&gt;
                 &lt;amount-approved&gt;4000&lt;/amount-approved&gt;
                 &lt;amount-drawn&gt;2105&lt;/amount-drawn&gt;
                 &lt;monthly-installment&gt;0&lt;/monthly-installment&gt;
                 &lt;outstanding-performing-principal&gt;2105&lt;/outstanding-performing-principal&gt;
                 &lt;outstanding-overdue-principal&gt;0&lt;/outstanding-overdue-principal&gt;
                 &lt;balance-sheet-value&gt;2105&lt;/balance-sheet-value&gt;
                 &lt;off-balance-sheet-value&gt;1895&lt;/off-balance-sheet-value&gt;
              &lt;/summary&gt;
              &lt;summary&gt;
                 &lt;date-from&gt;2017-12-31&lt;/date-from&gt;
                 &lt;type&gt;Овърдрафт&lt;/type&gt;
                 &lt;amount-approved&gt;7434&lt;/amount-approved&gt;
                 &lt;amount-drawn&gt;7447&lt;/amount-drawn&gt;
                 &lt;monthly-installment&gt;0&lt;/monthly-installment&gt;
                 &lt;outstanding-performing-principal&gt;7434&lt;/outstanding-performing-principal&gt;
                 &lt;outstanding-overdue-principal&gt;13&lt;/outstanding-overdue-principal&gt;
                 &lt;balance-sheet-value&gt;7484&lt;/balance-sheet-value&gt;
                 &lt;off-balance-sheet-value&gt;0&lt;/off-balance-sheet-value&gt;
              &lt;/summary&gt;
           &lt;/summaries&gt;
           &lt;summaries&gt;
              &lt;grouping-attribute&gt;overdue-payment-period&lt;/grouping-attribute&gt;
              &lt;summary&gt;
                 &lt;date-from&gt;2017-12-31&lt;/date-from&gt;
                 &lt;overdue-payment-period&gt;от 0 до 30 дни&lt;/overdue-payment-period&gt;
                 &lt;amount-approved&gt;11434&lt;/amount-approved&gt;
                 &lt;amount-drawn&gt;9552&lt;/amount-drawn&gt;
                 &lt;monthly-installment&gt;0&lt;/monthly-installment&gt;
                 &lt;outstanding-performing-principal&gt;9539&lt;/outstanding-performing-principal&gt;
                 &lt;outstanding-overdue-principal&gt;13&lt;/outstanding-overdue-principal&gt;
                 &lt;balance-sheet-value&gt;9589&lt;/balance-sheet-value&gt;
                 &lt;off-balance-sheet-value&gt;1895&lt;/off-balance-sheet-value&gt;
              &lt;/summary&gt;
           &lt;/summaries&gt;
           &lt;summaries&gt;
              &lt;grouping-attribute&gt;rest&lt;/grouping-attribute&gt;
              &lt;summary&gt;
                 &lt;date-from&gt;2017-12-31&lt;/date-from&gt;
                 &lt;rest&gt;До една година&lt;/rest&gt;
                 &lt;amount-approved&gt;7434&lt;/amount-approved&gt;
                 &lt;amount-drawn&gt;7447&lt;/amount-drawn&gt;
                 &lt;monthly-installment&gt;0&lt;/monthly-installment&gt;
                 &lt;outstanding-performing-principal&gt;7434&lt;/outstanding-performing-principal&gt;
                 &lt;outstanding-overdue-principal&gt;13&lt;/outstanding-overdue-principal&gt;
                 &lt;balance-sheet-value&gt;7484&lt;/balance-sheet-value&gt;
                 &lt;off-balance-sheet-value&gt;0&lt;/off-balance-sheet-value&gt;
              &lt;/summary&gt;
              &lt;summary&gt;
                 &lt;date-from&gt;2017-12-31&lt;/date-from&gt;
                 &lt;rest&gt;Над една година&lt;/rest&gt;
                 &lt;amount-approved&gt;4000&lt;/amount-approved&gt;
                 &lt;amount-drawn&gt;2105&lt;/amount-drawn&gt;
                 &lt;monthly-installment&gt;0&lt;/monthly-installment&gt;
                 &lt;outstanding-performing-principal&gt;2105&lt;/outstanding-performing-principal&gt;
                 &lt;outstanding-overdue-principal&gt;0&lt;/outstanding-overdue-principal&gt;
                 &lt;balance-sheet-value&gt;2105&lt;/balance-sheet-value&gt;
                 &lt;off-balance-sheet-value&gt;1895&lt;/off-balance-sheet-value&gt;
              &lt;/summary&gt;
           &lt;/summaries&gt;
           &lt;summaries&gt;
              &lt;grouping-attribute&gt;term&lt;/grouping-attribute&gt;
              &lt;summary&gt;
                 &lt;date-from&gt;2017-12-31&lt;/date-from&gt;
                 &lt;term&gt;Над една година&lt;/term&gt;
                 &lt;amount-approved&gt;11434&lt;/amount-approved&gt;
                 &lt;amount-drawn&gt;9552&lt;/amount-drawn&gt;
                 &lt;monthly-installment&gt;0&lt;/monthly-installment&gt;
                 &lt;outstanding-performing-principal&gt;9539&lt;/outstanding-performing-principal&gt;
                 &lt;outstanding-overdue-principal&gt;13&lt;/outstanding-overdue-principal&gt;
                 &lt;balance-sheet-value&gt;9589&lt;/balance-sheet-value&gt;
                 &lt;off-balance-sheet-value&gt;1895&lt;/off-balance-sheet-value&gt;
              &lt;/summary&gt;
           &lt;/summaries&gt;
        &lt;/active-credits&gt;
        &lt;overdue-history /&gt;
        &lt;new-credits /&gt;
     &lt;/section&gt;
  &lt;/borrower&gt;</code></pre>
  </div>
  </div>
  </p>