users@jaxb.java.net

1.0-beta: getContent() usage??

From: Irv Thomae <ithomae_at_ists.dartmouth.edu>
Date: Wed, 04 Dec 2002 14:55:02 -0500

This question doesn't seem to be addressed either in the generally very
helpful Users' Guide, nor anywhere that I could find in comp.lang.java*
or comp.text.xml .
   When the Schema Compiler processes the following schema fragment

  <xsd:complexType name="routerReport" mixed="true">
    <xsd:sequence>
      <xsd:element name="adds" type="xsd:int" maxOccurs="1"/>
      <xsd:element name="drops" type="xsd:int" maxOccurs="1"/>
    </xsd:sequence>
    <xsd:attribute name="name" type="xsd:string" use="required"/>
  </xsd:complexType>

it generates this file, named "RouterReport.java" (generated comments
omitted or condensed for brevity):

public interface RouterReport {

    String getName();
    void setName(String value);

    java.util.List getContent();


    /**
     * The following schema fragment specifies the expected content
contained within this java content object.
     * <element name="adds" type="{http://www.w3.org/2001/XMLSchema}int"/>
     */
    public interface Adds {
        int getValue();
        void setValue(int value);
    }


    /**
     * The following schema fragment specifies the expected content
contained within this java content object.
     * <element name="drops" type="{http://www.w3.org/2001/XMLSchema}int"/>
     */
    public interface Drops {
        int getValue();
        void setValue(int value);
    }
}

Although the schema fragment shown appears to follow the same pattern as
"PurchaseOrderType" in the users-guide SampleApp1, the code produced by
the Schema Compiler does not match "PurchaseOrderType.java". In the
sample code, interface PurchaseOrderType has a pair of getXxx() and
setXxx() methods for each named element. The generated
"RouterReport.java", however, has getYyy() and setYyy() methods only for
the attribute (in this case, "name").
     Is there any way to force the above schema fragment to generate
file(s) that do match the SampleApp code, i.e.,
    interface RouterReport
    {
        int getAdds();
        void setAdds(int);

        int getDrops();
        void setDrops();

        String getName();
        void setName(String);
     }

    If not, how is the method java.util.List getContent() supposed
to be used? Does the returned List contain alternating "Adds" and
"Drops" objects? It sounds much more cumbersome than the SampleApp
implies.....

Thank you,
  Irv Thomae
  ISTS./Dartmouth College