users@jaxb.java.net

JAXB one-to-many relationship problems.

From: SUBSCRIBE JAXB-INTEREST CBroussard <CBroussard_at_kcp.com>
Date: Tue, 08 Apr 2003 10:25:16 -0500

Hi All,

I'm relatively new to jaxb and am experiencing problems.

I'm trying to bind a one to many relationship and it doesn't seem to work
for me.

a sample xml file would be

<root>
      <book>
            <title />
            <authors>
                  <author>
                        <firstname />
                        <lastname />
                  </author>
                  <author>
                        <firstname />
                        <lastname />
                  </author>
            </authors>
      </book>
</root>

i'm trying to bind through xml schemas instead of dtd.

here's a sniplet.

<xsd:complexType name="AuthorsType">
      <xsd:sequence>
            <xsd:element name="author" type="author" maxOccurs="unbounded"
/>
      </xsd:sequence>
</xsd:complexType>

<xsd:complexType name="author">
      <xsd:sequence>
            <xsd:element name="firstname" type="xsd:string" />
            <xsd:element name="lastname" type="xsd:string" />

      </xsd:sequence>
</xsd:complexType>

when i run it through xjc, it generates the interface of

public interface AuthorsType {
    java.util.List getAuthor();
}

i want to see something like this???

public interface AuthorsType {
    java.util.List getAuthor();
   void setAuthor(int index, Author author);
}

interface Author generates the correct interface.

What am I doing wrong? I have tried many different configurations for the
xsd file. However, this is the closest I've gotten thus far.

Thanks,

Chris