Hi Maria, First off, xsd2jibx is officially and forever dead. The replacement for xsd2jibx is CodeGen, included in the 1.2 release, and CodeGen should generate a class structure which reflects the complexType extension structure of the schema (so in your example, the Detail1 and Detail2 classes should each extend the Base class).
Schema polymorphism is a more complex issue. There are two forms of polymorphism supported by schema: Element substitution groups, and xsi:type metadata at runtime. The difference between the two in instance documents is that with substitution groups you actually use different element names in an instance document depending on the type of data you want to represent, while with xsi:type you use the same element name but add a magic attribute which identifies the schema type of the value. Each of these approaches has some advantages and disadvantages. JiBX currently supports only the element substitution group form of polymorphism. xsi:type substitution support is planned for JiBX 2.0. I'm releasing a 1.2.1 version later today (mostly because of code generation fixes for some schema variations), and will have a 1.2.2 release by the end of the month with more bug fixes. After that I'm hoping to start serious work on 2.0. - Dennis Dennis M. Sosnoski SOA and Web Services in Java Training and Consulting http://www.sosnoski.com - http://www.sosnoski.co.nz Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117 Maria Aschauer wrote: > hi, > first i'd like to thank dennis for his great work for jibx 1.2 release. > one important question is still unclear for me - the current status of > inheritance and polymorphism during marshalling, unmarshalling and also > code generation. some results seem to be correct for my point of view, > but for some processing parts i would have expected different results. > > - MARSHALLING: marshalling for inherited types works correctly, but > there is no detail info added to the xml, like an attribute > type="Detail1" or type="Detail2" for the sample below, known from other > o/x-mappers: > > <data> > <detail> > <id>1234</id> > </detail> > <detail> > <id>1234</id> > <description>description</description> > </detail> > <detail> > <id>1234</id> > <status>OK</status> > </detail> > </data> > > - UNMARSHALLING: unmarshalling is not possible because <detail>-tag is > not type-safe > > - CODE GENERATION: xsd2java code generation tool, does not generate > expected inheritance in java classes shown in the sample below. > > SAMPLE: > --------------------------------------------------------- > XSD (using inheritance in .xsd instead of choice) > --------------------------------------------------------- > <xsd:complexType name="Base"> > <xsd:sequence> > <xsd:element name="id" type="xsd:string" /> > </xsd:sequence> > </xsd:complexType> > > <xsd:complexType name="Detail1"> > <xsd:complexContent> > <xsd:extension base="Base"> > <xsd:sequence> > <xsd:element name="description" type="xsd:string" /> > </xsd:sequence> > </xsd:extension> > </xsd:complexContent> > </xsd:complexType> > > <xsd:complexType name="Detail2"> > <xsd:complexContent> > <xsd:extension base="Base"> > <xsd:sequence> > <xsd:element name="status" type="xsd:string" /> > </xsd:sequence> > </xsd:extension> > </xsd:complexContent> > </xsd:complexType> > > <xsd:element name="data"> > <xsd:complexType> > <xsd:sequence> > <xsd:element name="detail" type="Base" /> > <xsd:element name="detail" type="Detail1" /> > <xsd:element name="detail" type="Detail2" /> > </xsd:sequence> > </xsd:complexType> > </xsd:element> > --------------------------------------------------------- > > --------------------------------------------------------- > JAVA CLASSES (self written) > --------------------------------------------------------- > public class Base { > public String id; > } > > public class Detail1 extends Base{ > public String description; > } > > public class Detail2 extends Base{ > public String status; > } > --------------------------------------------------------- > > --------------------------------------------------------- > BINDING (self written) > --------------------------------------------------------- > <mapping type-name="Base" class="Base" abstract="true"> > <value style="element" name="id" field="id"/> > </mapping> > > <mapping type-name="Detail1" class="Detail1" abstract="true"> > <structure map-as="Base" /> > <value style="element" name="description" field="description"/> > </mapping> > > <mapping type-name="Detail2" class="Detail2" abstract="true"> > <structure map-as="Base" /> > <value style="element" name="status" field="status"/> > </mapping> > > <mapping name="data" class="Data"> > <structure map-as="Base" field="base" name="detail" /> > <structure map-as="Detail1" field="base" name="detail" /> > <structure map-as="Detail2" field="base" name="detail" /> > </mapping> > --------------------------------------------------------- > > > > > > ------------------------------------------------------------------------------ > _______________________________________________ > jibx-users mailing list > jibx-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/jibx-users > > ------------------------------------------------------------------------------ Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are powering Web 2.0 with engaging, cross-platform capabilities. Quickly and easily build your RIAs with Flex Builder, the Eclipse(TM)based development software that enables intelligent coding and step-through debugging. Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com _______________________________________________ jibx-users mailing list jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users