users@jaxb.java.net

Re: JAXB or schema problem?

From: Christopher Holm <them4z_at_googlemail.com>
Date: Mon, 21 May 2007 19:21:22 +0200

$ xjc -version
xjc version "JAXB 2.0 in JDK 1.6"
JavaTM Architecture for XML Binding(JAXB) Reference Implementation,
(build JAXB 2.0 in JDK 1.6)


On 5/21/07, Aleksei Valikov <valikov_at_gmx.net> wrote:
> Hi.
>
>
>
> > I'm having a problem with a certain schema and I can't figure out if
> > JAXB does what it should and it is a problem with the schema, or if
> > the schema is correct but JAXB does things in an unappropriate way.
> >
> > First of all, here is a snippet of the schema:
> > [snip]
> > <xsd:group name="foo_type">
> > <xsd:choice>
> > <xsd:element name="a_type" type="foo_typeType" />
> > <xsd:element name="b_type" type="foo_typeType" />
> > [...more of those...]
> > </xsd:choice>
> > </xsd:group>
> > [/snip]
> >
> > Now the problem is the following:
> > If I feed the schema into JAXBs xjc, it generates a class
> > foo_typeType, and I have no way of determining if the Object was of
> > type a_type, b_type, ...
> >
> > Since a_type, b_type, etc. all have the same (optional) attributes
> > (and so, setters and getters in JAXB), i think the schema definition
> > makes sense that way. Additionaly, in the xml-files, the declarations
> > as follows:
> > [snip]
> > <a_type some_attr="foo" [...]/>
> > <b_type some_attr="bar" [...]/>
> > [/snip]
> > So, the information I need is all there.
> >
> >
> > But, why does JAXB "forget" the information? There seems to be no way
> > for me to determine if my foo_typeType-Object was a_type, b_type and
> > so on, neither via an attribute in foo_typeType, nor is there a class
> > a_type that I could test with eg. instanceof.
> >
> >
> > So, is our schema wrong and we should go back and rewrite it (and it
> > what way?), or is it a misbehavior in JAXB, or is it somewhere in JAXB
> > and I simply am too blind to see it?
>
> Which JAXB version do you use? 1 or 2?
>
> Bye.
> /lexi
>
>


-- 
Mit freundlichen Grüßen,
    Christopher "m4z" Holm