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
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users