Irv Thomae wrote:
> 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">
Mixed content has to be supported as a list of Elements and text.
See Section 5.9.3 and 5.9.4 in JAXB specification on how to use
the list and WHY it is a necessary binding.
Drop mixed="true" and you would get property accessors as expected.
With mixed="true" you are manipulating marked up text, not something
that binds well to a data structure.
-Joe
> <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
--