Kostis Anagnostopoulos wrote:
> Hi to all,
>
> When i try to marshal a schema type-derived java object containing
> only attributes then i get an empty string, although its attributes
> have values.
You mean, you get:
<executionInfo transformerProgramVersion="..."
configFile="..."
configFileVersion="..."></executionInfo>
as the output? Or just <executionInfo></executionInfo> (or
<executionInfo />) without any attribute values?
> See for instance the "executionInfoType" at the end of the mail.
I saw the schema definition but not the instance.
>
> When i modified my schema, and added on nested element, and
> additionally set it indeed to something, then i got all content
> (attributes plus nested element).
>
> Alternatively, i worked around that problem by adding one top-level
> element of "executionInfo" type, and used that element for marshaling.
Ah, that's why. In JAXB 1.x, you can't just marshal an object that
represents a type. You always need to marshal an instance that maps to
an element.
I believe there's a general purpose element wrapper code somewhere in
the archive, which is useful for cases like this.
Maybe this?
https://jaxb.dev.java.net/servlets/ReadMsg?listName=users&msgNo=997
> I don't know whether this is considered "normal" (I've found some
> similar old threads), but either way i believe that 2 actions has to
> be taken:
> 1. a notification should be included into the "Limitations" section
> of the Release Notes,
> 2. the marshaller should throw an Exception when marshaling types
> into empty strings.
>
> Should i file an issue ?
I agree with you, but I'm afraid we have very limited resources for
fixing problems in JAXB RI 1.0.x line of code.
If you can write a patch to fix them, I'd be very happy to apply it.
--
Kohsuke Kawaguchi
Sun Microsystems kohsuke.kawaguchi_at_sun.com