users@jaxb.java.net

XmlRootElement annotation not added on base class

From: Nagaraj Mandya <nmandya_at_gmail.com>
Date: Wed, 5 Aug 2009 15:10:41 -0700

Hello,
I have a schema that looks like this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" targetNamespace="http://foo"
   xmlns:foo="http://foo"
  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="abcd" type="foo:abcd"/>

  <xs:element name="efgh" type="foo:efgh"/>

  <xs:complexType name="abcd">
    <xs:sequence>
      <xs:element name="test" type="xs:string" minOccurs="0"/>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="efgh">
    <xs:complexContent>
      <xs:extension base="foo:abcd">
        <xs:sequence>
          <xs:element name="temp" type="xs:string" minOccurs="0"/>
        </xs:sequence>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>
</xs:schema>

I then generate Java classes from this using xjc -extension. In the
generated classes, only Efgh is annotated with XmlRootElement, while Abcd is
not. Why is that? I want both of them annotated as root elements as I need
to use both of them as roots.

I am using the xjc that is bundled with JDK 1.6.0_06. Thanks.
--
Nagaraj