users@jaxb.java.net

Re: is it possible to generate inherited classes with JAXB?

From: R7 <linan_at_zju.edu.cn>
Date: Mon, 8 Mar 2010 17:23:22 -0800 (PST)

thank you for your answer.
however, in our case we are not allowed to modify the schema, so we cannot
change the style of the schema to xs:extension.
is there any other ways , or any other tools can do the job?

Wolfgang Laun-2 wrote:
>
> You won't get calss hierarchies just by pulling in element or attribute
> groups, whose ref's are treated just like text substitutions.
>
> You should use xs:extension. Look into
> https://jaxb.dev.java.net/tutorial/section_2_2_13-Defining-Subtypes.html#Defining%20Subtypesfor
> details.
>
> -W
>
> On Mon, Mar 8, 2010 at 9:56 AM, R7 <linan_at_zju.edu.cn> wrote:
>>
>> We are dealing with an schema with a great amount of data and with JAXB,
> over
>> 500 classes are generated. We wonder whether it's possible to generate
>> inherited classes with JAXB.
>> For example, a simple piece of schema is shown below:
>> <?xml version="1.0" encoding="UTF-8"?>
>> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
>> <xs:group name = "person">
>> <xs:sequence>
>> <xs:element name = "FirstName" type =
>> "xs:string"/>
>> <xs:element name = "FamilyName" type =
> "xs:string"/>
>> </xs:sequence>
>> </xs:group>
>> <xs:complexType name = "person">
>> <xs:sequence>
>> <xs:group ref = "person"/>
>> </xs:sequence>
>> </xs:complexType>
>> <xs:group name = "student">
>> <xs:sequence>
>> <xs:element name = "No" type = "xs:integer"/>
>> </xs:sequence>
>> </xs:group>
>> <xs:complexType name = "student">
>> <xs:sequence>
>> <xs:group ref = "person"/>
>> <xs:group ref = "student"/>
>> </xs:sequence>
>> </xs:complexType>
>> </xs:schema>
>> and JAXB will generate something like
>> public class person{
>> protected String firstname;
>> protected String familyname;
>> }
>>
>> public class student{
>> protected String firstname;
>> protected String familyname;
>> protected BigInteger no;
>> }
>> is it possible to generate the student class as subclass of person?
>> something like
>> public class student extends person{
>> protected BigInteger no;
>> }
>>
>> --
>> View this message in context:
> http://old.nabble.com/is-it-possible-to-generate-inherited-classes-with-JAXB--tp27818621p27818621.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
>>
>>
>
>

-- 
View this message in context: http://old.nabble.com/is-it-possible-to-generate-inherited-classes-with-JAXB--tp27818621p27830172.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.