title: XSD generate a MAP<String, Boolean> properties
body: <p>I am trying to generate java class from XSD file, which contains <code>Map&lt;String, Boolean</code>. I've read tutorial (<a href="http://todayguesswhat.blogspot.co.uk/2012/09/jaxb-xsd-to-java-maphashmap-example.html" rel="nofollow noreferrer">http://todayguesswhat.blogspot.co.uk/2012/09/jaxb-xsd-to-java-maphashmap-example.html</a>) which says that I have to use Adapter and Binding in order to achieve desired result. </p>
  
  <p>But for some reason after generation property is a <code>List</code> instead of the <code>Map</code>. Could you please help me to figure out my mistake?</p>
  
  <p>Thanks!</p>
  
  <p>My XSD schema:
  
  </p>
  
  <pre><code>&lt;xs:element name="AutoCompleteReq"&gt;
    &lt;xs:complexType&gt;
     &lt;xs:sequence&gt;
      &lt;xs:element name="queryString" type="xs:string"/&gt;
      &lt;xs:element name="boostingFactors" type="test:StringBooleanMapModeller" minOccurs="0"/&gt;
     &lt;/xs:sequence&gt;
    &lt;/xs:complexType&gt;
  &lt;/xs:element&gt;
  
  &lt;xs:complexType name="StringBooleanMapModeller"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="entry" minOccurs="0" maxOccurs="unbounded"&gt;
       &lt;xs:complexType&gt;
        &lt;xs:sequence&gt;
          &lt;xs:element name="key" type="xs:string"/&gt;
          &lt;xs:element name="value" type="xs:boolean"/&gt;
        &lt;/xs:sequence&gt;
       &lt;/xs:complexType&gt;
     &lt;/xs:element&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
  </code></pre>
  
  <p></p>
  
  <p>My Binding file:</p>
  
  <p></p>
  
  <pre><code>&lt;jaxb:bindings schemaLocation="AutoCompleteReq.xsd"&gt;
  
    &lt;jaxb:bindings node="//xs:element[@name='AutoCompleteReq']//xs:element[@name='boostingFactors']"&gt;
     &lt;jaxb:property&gt;
      &lt;jaxb:baseType name="com.company.support.jaxb.StringBooleanMap&amp;lt;String,Boolean&amp;gt;" /&gt;
     &lt;/jaxb:property&gt;
    &lt;/jaxb:bindings&gt;
  
  &lt;/jaxb:bindings&gt;
  
  &lt;/jaxb:bindings&gt;
  </code></pre>
  
  <p>StringBooleanMap.java</p>
  
  <pre><code>package com.company.support.jaxb;
  
  import java.util.HashMap;
  
  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  
  @XmlJavaTypeAdapter(StringBooleanMapAdapter.class)
  public class StringBooleanMap&lt;String, Boolean&gt; extends HashMap&lt;String, Boolean&gt; {
  
  }
  </code></pre>
  
  <p>StringBooleanMapAdapter.java</p>
  
  <pre><code>package com.company.support.jaxb;
  
  import java.util.HashMap;
  import java.util.Map;
  
  import javax.xml.bind.annotation.adapters.XmlAdapter;
  
  import com.company.xml.representation.StringBooleanMapModeller;
  
  public class StringBooleanMapAdapter extends XmlAdapter&lt;StringBooleanMapModeller, HashMap&lt;String, Boolean&gt;&gt; {
  
      @Override
      public HashMap&lt;String, Boolean&gt; unmarshal(StringBooleanMapModeller v)
              throws Exception {
  
          HashMap&lt;String, Boolean&gt; map = new HashMap&lt;String, Boolean&gt;();
          for(StringBooleanMapModeller.Entry e : v.getEntry())
          {
              map.put(e.getKey(), e.isValue());
          }
  
          return map;
      }
  
      @Override
      public StringBooleanMapModeller marshal(HashMap&lt;String, Boolean&gt; v)
              throws Exception {
  
          StringBooleanMapModeller modeller = new StringBooleanMapModeller();
          for(Map.Entry&lt;String, Boolean&gt; entry : v.entrySet())
          {
              StringBooleanMapModeller.Entry e = new StringBooleanMapModeller.Entry();
              e.setKey(entry.getKey());
              e.setValue(entry.getValue());
              modeller.getEntry().add(e);
          }
          return modeller;
      }
  }
  </code></pre>
  
  <p>pom.xml (piece for XSD generation)</p>
  
  <pre><code>&lt;plugin&gt;
                  &lt;groupId&gt;org.codehaus.mojo&lt;/groupId&gt;
                  &lt;artifactId&gt;jaxb2-maven-plugin&lt;/artifactId&gt;
                  &lt;version&gt;1.3&lt;/version&gt;
                  &lt;executions&gt;
                      &lt;execution&gt;
                          &lt;id&gt;Representations&lt;/id&gt;
                          &lt;configuration&gt;
                              &lt;schemaDirectory&gt;XSD/Representation&lt;/schemaDirectory&gt;
                              &lt;packageName&gt;com.company.xml.representation&lt;/packageName&gt;
                              &lt;bindingDirectory&gt;XSD/Representation&lt;/bindingDirectory&gt;
                              &lt;outputDirectory&gt;src/main/generated-sources&lt;/outputDirectory&gt;
                              &lt;staleFile&gt;${project.build.directory}/generated-sources/jaxb/.representation&lt;/staleFile&gt;
                              &lt;clearOutputDir&gt;false&lt;/clearOutputDir&gt;
                          &lt;/configuration&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;xjc&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                      &lt;execution&gt;
                          &lt;id&gt;Events&lt;/id&gt;
                          &lt;configuration&gt;
                              &lt;schemaDirectory&gt;XSD/Representation/Event&lt;/schemaDirectory&gt;
                              &lt;packageName&gt;com.company.xml.representation.event&lt;/packageName&gt;
                              &lt;bindingDirectory&gt;XSD/Representation/Event&lt;/bindingDirectory&gt;
                              &lt;outputDirectory&gt;src/main/generated-sources&lt;/outputDirectory&gt;
                              &lt;staleFile&gt;${project.build.directory}/generated-sources/jaxb/.event&lt;/staleFile&gt;
                              &lt;clearOutputDir&gt;false&lt;/clearOutputDir&gt;
                          &lt;/configuration&gt;
                          &lt;goals&gt;
                              &lt;goal&gt;xjc&lt;/goal&gt;
                          &lt;/goals&gt;
                      &lt;/execution&gt;
                  &lt;/executions&gt;
              &lt;/plugin&gt;
  </code></pre>