users@jaxb.java.net

[jaxb-1.x] Marshalling just a type without nested elements produces empty string

From: Kostis Anagnostopoulos <ankostis_at_gmail.com>
Date: Sat, 1 Jul 2006 01:24:59 +0300

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.

See for instance the "executionInfoType" at the end of the mail.

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.

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 ?


Below is the schema i use:
----------------------------------------------------------------------------------------

<xsd:schema
  <xsd:complexType name="executionInfoType">
    <xsd:attribute name="transformerProgramVersion" type="xsd:string"
      use="required" />
    <xsd:attribute name="transformationDate" type="xsd:dateTime"
      use="optional" />
    <xsd:attribute name="configFile" type="xsd:string" use="required" />
    <xsd:attribute name="configFileVersion" type="xsd:string"
      use="required" />
  </xsd:complexType>
</xsd:schema>
----------------------------------------------------------------------------------------


Greetings
      ankostis