users@jaxb.java.net

Re: Substituting a type's List property for the type itself

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Tue, 19 Dec 2006 10:29:45 -0800

Chris Nokleberg wrote:
> 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();

Yeah, I understand. It would be really nice if we can do this.

> 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?

Unfortunately, no easy way right now.

> 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.

This should be easy.


-- 
Kohsuke Kawaguchi
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com