users@jaxb.java.net

RE: Flattenning complex XSD structure during Java classes generation

From: Gary Gregory <GGregory_at_seagullsoftware.com>
Date: Tue, 26 Jan 2010 13:01:28 -0500

You could define your own schema, exactly as you like it, generate JAXB code from that, and use XSL to feed it instances of documents.

Gary
> -----Original Message-----
> From: Jeremy JGR. Grumbach [mailto:JGR_at_pulsar.be]
> Sent: Tuesday, January 26, 2010 09:27
> To: users_at_jaxb.dev.java.net
> Subject: Flattenning complex XSD structure during Java classes
> generation
>
> Hi all,
>
> I would like to know if it is possible (maybe by using JAXB
> customizations) to simplify/flatten the generated Java classes
> structure. The reason is that my XSD is quite complex with a lot of
> levels which are really annoying for my Java application (and I
> *cannot* change the XSD).
>
> In the example below, I would like to merge the fields of classes B and
> C in a single "BC" class.
>
> Example:
>
> Here is an XSD:
>
> -------------------------------------------------
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
> <xs:element name="B" type="BType"/>
> <xs:complexType name="BType">
> <xs:sequence>
> <xs:element name="C" type="CType"/>
> <xs:element name="FieldB1" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> <xs:complexType name="CType">
> <xs:sequence>
> <xs:element name="FieldC1" type="xs:string"/>
> <xs:element name="FieldC2" type="xs:string"/>
> </xs:sequence>
> </xs:complexType>
> </xs:schema>
> -------------------------------------------------
>
> JAXB generation results in the following two classes: BType.java and
> CType.java
>
> -------------------------------------------------
> public class BType {
>
> protected CType c;
> protected String fieldB1;
>
> [...]
>
> }
>
> public class CType {
>
> protected String fieldC1;
> protected String fieldC2;
>
> [...]
>
> }
> -------------------------------------------------
>
> And I would like to merge these two classes to have something like that
>
> -------------------------------------------------
> public class BCType {
>
> protected String fieldB1;
> protected String fieldC1;
> protected String fieldC2;}
> -------------------------------------------------
>
> Thanks!
>
> Jeremy
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net