users@jaxb.java.net

Re: XmlRootElement annotation not added on base class

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Sun, 9 Aug 2009 13:05:13 +0200

Did you try this without <xjc:simple>? If this is not essential, try to do
without this experimental feature.
-W

On Thu, Aug 6, 2009 at 12:10 AM, Nagaraj Mandya <nmandya_at_gmail.com> wrote:

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