JAXB generated XSD validation error "Unique Particle Attribution"
<p>I have a JAXB class, which has an element coming from another namespace. I would like to have an ANY element as well, which collects all the elements not described in the JAXB class. So I added a <code>List&lt;Object&gt;</code> annotated with the @XmlAnyElement.</p>

<p>I have generated an XSD from the JAXB class, but when I am validating I am getting an error: "cos-nonambig: "nb":b and WC[##other:""] (or elements from their substitution group) violate "Unique Particle Attribution". During validation against this schema, ambiguity would be created for those two particles."</p>

<p>The JAXB class</p>

<pre><code>@XmlAccessorType(XmlAccessType.FIELD)
@XmlType
public class Foo {

  @XmlElement
  String a;

  @XmlElement(namespace="nb")
  Bar b;

  @XmlAnyElement
  List&lt;Object&gt; other;
}
</code></pre>

<p>The XSD generated by JAXB</p>

<pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;xs:schema version="1.0" xmlns:ns1="nb" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;

  &lt;xs:import namespace="nb" schemaLocation="schema1.xsd"/&gt;

  &lt;xs:complexType name="foo"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="a" type="xs:string" minOccurs="0"/&gt;
      &lt;xs:element ref="ns1:b" minOccurs="0"/&gt;
      &lt;xs:any processContents="skip" namespace="##other" minOccurs="0" maxOccurs="unbounded"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;

  &lt;xs:complexType name="bar"&gt;
    &lt;xs:sequence&gt;
      &lt;xs:element name="bid" type="xs:string" minOccurs="0"/&gt;
    &lt;/xs:sequence&gt;
  &lt;/xs:complexType&gt;
&lt;/xs:schema&gt;
</code></pre>

<pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
&lt;xs:schema version="1.0" targetNamespace="nb" xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt;

  &lt;xs:import schemaLocation="schema2.xsd"/&gt;

  &lt;xs:element name="b" type="bar"/&gt;
&lt;/xs:schema&gt;
</code></pre>

<p>How should I add the XmlAnyElement to pass the validation?</p>