users@jaxb.java.net

Re: How to force JAXB to generate correct output for derived classes

From: Wolfgang Laun <wolfgang.laun_at_gmail.com>
Date: Tue, 21 Jul 2009 13:33:18 +0200

What do you see that is wrong?
-W



On Mon, Jul 20, 2009 at 7:05 PM, Qzpmwo <qzpmwo_at_gmail.com> wrote:

>
> Hi,
>
> I'm having a problem with derived schema types and XML generated by JAXB.
>
> Basically I'm having a schema like:
>
> <xs:schema>
>
> <xs:complexType name="BaseType">
> <xs:sequence>
> </xs:sequence>
> </xs:complexType>
>
> <xs:complexType name="DerivedType">
> <xs:complexContent>
> <xs:extension base="BaseType">
> <xs:sequence>
> </xs:sequence>
> </xs:extension>
> </xs:complexContent>
> </xs:complexType>
>
> <xs:complexType name="ListType">
> <xs:sequence>
> <xs:element name="item" type="BaseType" minOccurs="0"
> maxOccurs="unbounded" />
> </xs:sequence>
> </xs:complexType>
>
> <xs:element name="base" type="BaseType" />
> <xs:element name="derived" type="DerivedType" />
> <xs:element name="list" type="ListType" />
>
> </xs:schema>
>
> XJC is used to generate java classes from this schema.
>
> 1) @XmlSeeAlso pointing to DerivedType class and @XmlRootElement
> annotations have been added to BaseType java class code
> 2) @XmlRootElement has been added to DerivedType java class code
> 3) @XmlRootElement has been added to ListType java class code
>
> Right xml is produced when I'm using ListType
>
> <list>
> <base xsi:type="DerivedType">...</base>
> ...
> </list>
>
> But when I'm trying to get single object of the DerivedType, I see wrong
> xml
> (since I'm not using substitution group):
>
> <derived>...</derived>
>
> So question: Is there a way to force JAXB return correct xml?
>
> Thanks in advance
> --- Karen
> --
> View this message in context:
> http://www.nabble.com/How-to-force-JAXB-to-generate-correct-output-for-derived-classes-tp24573728p24573728.html
> Sent from the java.net - jaxb users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>