title: JAXB : How to add attributes to an inner element
body: <p>I have the below XML that I want to read. Using JAXB on java 1.6, how do I annotate for the attribute regex ? Can I have the field to be of type boolean ?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  
   &lt;authStore&gt;
    &lt;authList&gt;
         &lt;auth&gt;
           &lt;resource&gt;res1&lt;/resource&gt;
           &lt;privilege regex = "true"&gt;PRIV_FILE_.+?_READ&lt;/privilege&gt;   
         &lt;/auth&gt;
         &lt;auth&gt;
           &lt;resource&gt;res2&lt;/resource&gt;
           &lt;privilege&gt;PRIV_FILE_READ&lt;/privilege&gt;   
         &lt;/auth&gt;
  &lt;/authStore&gt;
  </code></pre>
  
  <p>UPDATE : Is it possible to make the attribute optional ? If yes, when I unmarshal, will I get regex field to be false when a privilege element does not have the optional attribute regex ?</p>
  
  <p>UDPATE2 : I don't want to define separate classes for resource and privilege. Also, I don't want to use MOXy. Pls. suggest solution for sun/oracle JDK 1.6 JAXB only. </p>
  
  <p>UPDATE3 : My current object model is something like this</p>
  
  <pre><code>// AuthStore.java
  @XmlRootElement
  public class AuthStore {
  
      @XmlElementWrapper(name = "authList")
      @XmlElement(name = "auth")
      private ArrayList&lt;Auth&gt; authList;
  
      public void setAuthList(ArrayList&lt;Auth&gt; authList) {
          this.authList = authList;
      }
  
      public ArrayList&lt;Auth&gt; getAuthsList() {
          return authList;
      }
  }
  
  
  // Auth.java    
  @XmlRootElement(name = "auth")
  @XmlType(propOrder = { "resource", "privilege" })
  public class Auth
  {
      private String resource;
      private String privilege;
  
      @XmlElement(name = "resource")
      public String getResource()
      {
          return resource;
      }
  
      public void setResource(String resource)
      {
          this.resource = resource;
      }
  
      @XmlElement(name = "privilege")
      public String getPrivilege()
      {
          return privilege;
      }
  
      public void setPrivilege(String author)
      {
          this.privilege = author;
      }
  }
  </code></pre>