Hi,
I'm trying to make use of "simple binding" to have two complexTypes defined in a schema which both have @XmlRootElement annotation when generated, so they the sub-type can be marshalled individually (without requiring a surrounding root element).
I followed the instructions on
http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html and I am using the latest JAXB release, 2.0.2-b01-fcs. I added the <xs:annotation> block with <xjc:simple/>, and have extension="true" in my ant XJC task.
When the classes get generated, the MainElement class has @XmlRootElement on it, but the SubElement class does not. Any ideas?
In my schema I have something like this:
<xs:schema xmlns:xs="
http://www.w3.org/2001/XMLSchema" xmlns:jaxb="
http://java.sun.com/xml/ns/jaxb"
jaxb:version="2.0"
xmlns:xjc="
http://java.sun.com/xml/ns/jaxb/xjc"
jaxb:extensionBindingPrefixes="xjc">
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings>
<xjc:simple />
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="mainElement">
<xs:complexType >
<xs:sequence>
<xs:element name="subElement" type="subElement" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:appinfo>
<jaxb:property name="subElements"/>
</xs:appinfo>
</xs:annotation>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="subElement">
<xs:sequence>
<xs:element name="attr1" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="attr2" type="xs:string" minOccurs="1" maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
Thanks,
matias