title: Difficult JAXB mapping
body: <p>I am trying to map the following XML structure within a larger document, clearly this isn't the greatest use of XML ever but this is what I have to work with.</p>
  
  <p>Example simplified for clarity:</p>
  
  <pre><code>  &lt;details&gt;
      &lt;pictures&gt;
        &lt;picture1&gt;
          http://domain.com/path/picture1.jpg
        &lt;/picture1&gt;
        &lt;picture2&gt;
          http://domain.com/path/picture2.jpg
        &lt;/picture2&gt;
        &lt;picture3&gt;
          http://domain.com/path/picture3.jpg
        &lt;/picture3&gt;
        &lt;picture4&gt;
          http://domain.com/path/picture4.jpg
        &lt;/picture4&gt;
        &lt;picture5&gt;
          http://domain.com/path/picture5.jpg
        &lt;/picture5&gt;
        &lt;picture6&gt;
          http://domain.com/path/picture6.jpg
        &lt;/picture6&gt;
        &lt;picture7&gt;
          http://domain.com/path/picture7.jpg
        &lt;/picture7&gt;
      &lt;/pictures&gt;
    &lt;/details&gt;
  </code></pre>
  
  <p>There is a DTD for this document which declares that there will be up to 30 different picture elements numbered 1-30 with the names <code>&lt;picutre[n]/&gt;</code></p>
  
  <p>What I would like to do is, rather than create 30 different classes for each of these elements called Picture1, Picture2, Picture3 ... and so on. I would just like to use a single Picture class and use it for all 30 unique element names.</p>
  
  <p>Below is what I have tried so far.</p>
  
  <pre><code>@XmlRootElement
  public class Details {
  
     ...
  
     @XmlElementWrapper
     @XmlElementRefs({
          @XmlElementRef( name="picture1", type=Picture.class ),
          @XmlElementRef( name="picture2", type=Picture.class ),
          @XmlElementRef( name="picture3", type=Picture.class ),
          @XmlElementRef( name="picture4", type=Picture.class ),
          @XmlElementRef( name="picture5", type=Picture.class ),
          @XmlElementRef( name="picture6", type=Picture.class ),
          @XmlElementRef( name="picture7", type=Picture.class ),
          @XmlElementRef( name="picture8", type=Picture.class ),
          @XmlElementRef( name="picture9", type=Picture.class ),
          @XmlElementRef( name="picture10", type=Picture.class ),
          @XmlElementRef( name="picture11", type=Picture.class ),
          @XmlElementRef( name="picture12", type=Picture.class ),
          @XmlElementRef( name="picture13", type=Picture.class ),
          @XmlElementRef( name="picture14", type=Picture.class ),
          @XmlElementRef( name="picture15", type=Picture.class ),
          @XmlElementRef( name="picture16", type=Picture.class ),
          @XmlElementRef( name="picture17", type=Picture.class ),
          @XmlElementRef( name="picture18", type=Picture.class ),
          @XmlElementRef( name="picture19", type=Picture.class ),
          @XmlElementRef( name="picture20", type=Picture.class ),
          @XmlElementRef( name="picture21", type=Picture.class ),
          @XmlElementRef( name="picture22", type=Picture.class ),
          @XmlElementRef( name="picture23", type=Picture.class ),
          @XmlElementRef( name="picture24", type=Picture.class ),
          @XmlElementRef( name="picture25", type=Picture.class ),
          @XmlElementRef( name="picture26", type=Picture.class ),
          @XmlElementRef( name="picture27", type=Picture.class ),
          @XmlElementRef( name="picture28", type=Picture.class ),
          @XmlElementRef( name="picture29", type=Picture.class ),
          @XmlElementRef( name="picture30", type=Picture.class )
      })
     public List&lt;Picture&gt; getPictures() {
        return this.pictures;
     }
  
     public void setPictures( List&lt;Pictures&gt; pictures ) {
        this.pictures = pictures;
     }
  
     ...
  
  }
  
  @XmlElementWrapper
  public class Picture {
   ...
  }
  </code></pre>
  
  <p>This causes getPictures to return null always.</p>
  
  <p>Additionally I tried changing the annotation on the Picture class to be <code>@XmlElementWrapper( name="picture1" )</code> which resulted in me getting a list returned from getPictures() but only ever containing the <code>&lt;picture1/&gt;</code> element and never the rest.</p>
  
  <p>I know I can resort to getting a list of JAXBElement objects instead but I would rather not if I can avoid it. Any ideas how I can map this?</p>