users@jaxb.java.net

Re: How to use XML objects as members of other XML objects?

From: Kohsuke Kawaguchi <Kohsuke.Kawaguchi_at_Sun.COM>
Date: Mon, 12 May 2003 08:48:04 -0700

> 1. Why can't I use TESTA object instead of TESTAType one? Nothing
> prevents me to create invalid output.

I think our plan is to exploit this to support things like substitution
groups and type substitutions, if you accept this as a reason.

Another answer might be, TESTA object is defined as an element, so when
it's asked to marshal itself, it will marshal itself as a whole element.
So there's nothing the caller can do about it.

I guess both are not really satisfactory...


> 2. If I can't use TESTA object how can I "extract" TESTAType object from
> TESTA one (without copying by members)? In real code, TESTA is a
> complex object that I receive from the server. TESTB is another complex
> object that I send back to the server.

I'm afraid there's no easy way to do this, except copying members.


> 3. Any idea how to approach this problem if "this is not a bug, but a feature"?

I don't think it's a bug since it's behaving exactly as we expected, but
I agree that this is ugly.

One thing that the RI can relatively easily do is to have a
customization that generates:

    interface Foo {
        FooType getValue();
        void setValue(FooType t);
    }

instead of:

    interface Foo : FooType {
    }

which allows you to say:

    typebObject.setValue( typeaObject.getValue() );

this is analogous to the case when the type is a simple type.


Any comments appreciated. If we do this, does it help?

regards,
--
Kohsuke KAWAGUCHI                  408-276-7063 (x17063)
Sun Microsystems                   kohsuke.kawaguchi_at_sun.com