users@jaxb.java.net

Inherited classes

From: Vity <vitywap_at_seznam.cz>
Date: Wed, 16 Jul 2008 15:52:25 +0200

Hello,
I start with JAXB and I fight with XSD structure.

Consider following simplified XML structure (I can't change it):
<?xml version="1.0" ?>
<root>
   <foo>
      <x>1</x>
      <y>1</y>
      <q>string-value</q>
   </foo>
   <bar>
      <x>1</x>
      <y>1</y>
      <z>string-value</z>
   </bar>
</root>

I want to map same attributes to parent class like this:
public class FooBar { //this class should be generated
   protected int x; //mapped x
   protected int y; //mapped y
   //..getters and setters for x & y

}

public class Foo extends FooBar {
   protected String q;
   //..getter and setter for q
}

public class Bar extends FooBar {
   protected String z;
   //..getter and setter for z
}

I can't figure out how XSD should like. Is it possible to map elements into
classes like that? I use 6u10.

Thanks in advance.

-Vity