users@jaxb.java.net

Re: jaxb1 problem with complex-types vs elements

From: Christoph Sturm <christoph.sturm_at_gmail.com>
Date: Fri, 23 Jun 2006 17:50:29 +0200

hey ed!

attached you find a schema and a testcase.

this is the part of my ant file that compiles the schemas.
put the xsd file into a dir named xsd, and it should all work.

    <target name="xjc" depends="init">
        <xjc target="target/xjc" package="cc.lovo.types" extension="true">
            <schema dir="xsd">
                <include name="*.xsd"/>
            </schema>
        </xjc>
    </target>


thanks for looking at it!

regards
 chris

On 6/22/06, Ed Mooney <Ed.Mooney_at_sun.com> wrote:
> Hi Christoph,
>
> Could you send along a test case?
>
> Thanks,
> --
> Ed Mooney |Sun Microsystems, Inc.|Time flies like
> Java Web Services |UBUR02-201 |an arrow, but
> Ed.Mooney_at_Sun.COM |1 Network Drive |fruit flies like
> 781-442-0459 |Burlington, MA 01803 |a banana. Groucho
>
> Christoph Sturm wrote:
> > hey all!
> >
> > I am experiencing a strange effect in jaxb1:
> >
> > imagine i have one complex type and one element
> >
> > <xs:complex-type name="UserType" ....>
> >
> > <xs:element name="User" type="UserType"/>
> >
> > jaxb now creates a User class for me that extends UserType
> >
> > now i have another element that uses UserType
> >
> > <xs:element name="TypeThatContainsUserType">
> > <xs:complex-type>
> > <xs:element name="myUser" type="UserType"/>
> > </...>
> >
> > now I have TypeThatContainsUserType class, with a setMyUser(UserType)
> >
> > User extends UserType so i can pass a user to this setter.
> >
> > but when i then try to marshall this type i get a document that doesnt
> > validate, and i get an error message that looks something like this:
> >
> > org.xml.sax.SAXException: Invalid element in ....UserType - user
> >
> >
> > so my question is basically: why does the User class extend the
> > UserType class, if the marshalling creates incorrect xml then?
> >
> > is there a workaround?
> > am i doing something stupid?
> > is that also the case in jaxb2?
> >
> > thanks
> > chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
> For additional commands, e-mail: users-help_at_jaxb.dev.java.net
>
>


-- 
christoph.sturm_at_gmail.com