users@jaxb.java.net

Substituting a type's List property for the type itself

From: Chris Nokleberg <chris_at_sixlegs.com>
Date: Sun, 17 Dec 2006 11:53:26 -0800

Hi -

Sorry if this is a FAQ, the search interface on java.net is really poor.

I'm using JAXB to read MS Office Open XML documents. The final draft
schema is available here if anyone is interested:
http://www.ecma-international.org/news/TC45_current_work/OfficeOpenXML-XMLSchema.zip

Many of the elements in the schema have no attributes. Often they are
just containers for children elements. For example:

  <xsd:complexType name="CT_SlideIdList">
    <xsd:sequence>
      <xsd:element name="sldId" type="CT_SlideIdListEntry"
minOccurs="0" maxOccurs="unbounded">
        <xsd:annotation>
          <xsd:documentation>Slide ID</xsd:documentation>
        </xsd:annotation>
      </xsd:element>
    </xsd:sequence>
  </xsd:complexType>

This results in a class named "CTSlideIdList" which only has a single property:
  public List<CTSlideIdListEntry> getSldId();

Because there are no meaningful attributes I would much prefer to
eliminate the CTSlideIdList class completely, and just substitute a
List<CTSlideIdListEntry> everywhere it is currently referenced. There
is no ambiguity, even going the other way, because CTSlideIdListEntry
elements are always contained in a CT_SlideIdList. Is this possible?

One more issue... All the element and attribute names are heavily
abbreviated (e.g. "sld" for "slide", "lst" for "list"). Ideally I'd
like to plug in some Java code to expand these abbreviations globally
so that the resulting Java classes/properties have more readable
names.

Thanks,
Chris