title: JAXB external binding file xpath for sequence within complex type
body: <p>I have a question regarding the <code>node</code> xpath expression in <code>&lt;jxb:bindings\&gt;</code>:</p>
  
  <p>I have a type that I use multiple times in an xsd, specified in its own xsd:</p>
  
  <p>common.xsd:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;                                                                                                                                                                                                                                           
  &lt;xsd:schema                                                                                                                 
    targetNamespace="http://www.example.com/xsd/common"                                                                       
    xmlns="http://www.example.com/xsd/common"                                                                                 
    xmlns:tns="http://www.example.com/xsd/common"                                                                             
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"                                                                              
    elementFormDefault="qualified"&gt;                                                                                           
  
    &lt;xsd:complexType name="Parameter"&gt;
     &lt;xsd:simpleContent&gt;
       &lt;xsd:extension base="xsd:string"&gt;
          &lt;xsd:attribute name="key" type="xsd:string" use="required" /&gt;
        &lt;/xsd:extension&gt;
      &lt;/xsd:simpleContent&gt;
    &lt;/xsd:complexType&gt;
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>included multiple times in another schema:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsd:schema
    targetNamespace="http://www.example.com/xsd/example"
    xmlns="http://www.example.com/xsd/example"
    xmlns:tns="http://www.example.com/xsd/example"
    xmlns:c="http://www.example.com/xsd/common"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    elementFormDefault="qualified"&gt;
  
  &lt;xsd:element name="example" type="example" /&gt;
  
  &lt;xsd:complexType name="example"&gt;
    &lt;xsd:all&gt;
      &lt;xsd:element name="working" type="working" /&gt;
      &lt;xsd:element name="notworking" type="notworking" /&gt;
    &lt;/xsd:all&gt;
  &lt;/xsd:complexType&gt;
  
  &lt;xsd:complexType name="working"&gt;
    &lt;xsd:all&gt;
      &lt;xsd:element name="Parameters"&gt;
        &lt;xsd:sequence&gt;
          &lt;xsd:element name="Parameter" type="c:Parameter" maxOccurs="unbounded" /&gt;
        &lt;/xsd:sequence&gt;
      &lt;/xsd:element&gt;
    &lt;/xsd:all&gt;
  &lt;/xsd:complexType&gt;
  
  &lt;xsd:complexType name="notworking"&gt;
    &lt;xsd:sequence&gt;
      &lt;xsd:element name="Parameter" type="c:Parameter" maxOccurs="unbounded" /&gt;
    &lt;/xsd:sequence&gt;
    &lt;xsd:attribute name="anAttribute" type="xsd:token" /&gt;
  &lt;/xsd:complexType&gt;
  
  &lt;/xsd:schema&gt;
  </code></pre>
  
  <p>for binding with jaxb, I have a class ParameterMap:</p>
  
  <pre><code>package com.example.common.xml.model;
  
  import java.util.HashMap;
  import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
  import com.example.common.xml.binding.ParameterAdapter;
  
  @XmlJavaTypeAdapter(ParameterAdapter.class)
  public class ParameterMap extends HashMap&lt;String, String&gt; {}
  </code></pre>
  
  <p>as well as the adapter class:</p>
  
  <pre><code>package com.example.common.xml.binding;
  
  import java.util.Map;
  import java.util.List;
  import java.util.ArrayList;
  import javax.xml.bind.annotation.adapters.XmlAdapter;
  import com.example.common.xml.model.ObjectFactory;
  import com.example.common.xml.model.Parameter;
  import com.example.common.xml.model.ParameterMap;
  
  public class ParameterAdapter extends XmlAdapter&lt;List&lt;Parameter&gt;, ParameterMap&gt; {
    public ParameterMap unmarshal(List&lt;Parameter&gt; params) {
      ParameterMap map = new ParameterMap();
      for (Parameter p : params) {
        map.put(p.getKey(), p.getValue());
      }
      return map;
    }
  
    public List&lt;Parameter&gt; marshal(ParameterMap map) {
      List&lt;Parameter&gt; params = new ArrayList&lt;&gt;();
      ObjectFactory of = new ObjectFactory();
      for (Map.Entry&lt;String, String&gt; e : map.entrySet()) {
        Parameter p = of.createParameter();
        p.setKey(e.getKey());
        p.setValue(e.getValue());
        params.add(p);
      }
      return params;
    }
  }
  </code></pre>
  
  <p>and of course bindings files to make the classes Parameter and ObjectFactory be generated into the correct package. The bindings file for the example namespace is as follows:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;jxb:bindings version="1.0"
    xmlns:jxb="http://java.sun.com/xml/ns/jaxb"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:xjc="http://java.sun.com/xml/ns/jaxb/xjc"
    jxb:extensionBindingPrefixes="xjc"&gt;
  
    &lt;jxb:bindings schemaLocation="../pathTo/example.xsd" node="/xs:schema"&gt;
  
      &lt;jxb:bindings node="//xs:complexType[@name='working']//xs:element[@name='Parameters']"&gt;
        &lt;jxb:class name="com.example.common.xml.model.ParameterMap" /&gt;
      &lt;/jxb:bindings&gt;
  
      &lt;jxb:bindings node="//xs:complexType[@name='notworking']//xs:element[@name='Parameter']"&gt;
        &lt;jxb:class name="com.example.common.xml.model.ParameterMap" /&gt;
      &lt;/jxb:bindings&gt;
  
    &lt;/jxb:bindings&gt;
  
  &lt;/jxb:bindings&gt;
  </code></pre>
  
  <p>as you can tell from the naming, the binding for the child of <code>working</code> gets generated correctly, while the binding for <code>notworking</code> results in the generated class member</p>
  
  <pre><code>@XmlElement(name = "Parameter")
  protected List&lt;ParameterMap&gt; parameter;
  </code></pre>
  
  <p>what I would that like to look like would be the same as in <code>working</code>:</p>
  
  <pre><code>@XmlElement(name="Parameters")
  protected ParameterMap parameters;
  </code></pre>
  
  <p>I'm not flashed by "Parameter" vs "Parameters", but the type is wrong - any help on how to achieve that would be appreciated.</p>
  
  <p>I also already tried applying the <code>notworking</code> binding to the sequence (via <code>node="//xs:complexType[@name='notworking']/xs:sequence"</code>) but that just gets ignored. If I try to apply it directly on the <code>notworking</code> complexType it results in a parse error.</p>