users@jaxb.java.net

Marshalling list types

From: Jörg Meister <jm_at_joergmeister.de>
Date: Mon, 11 Oct 2004 20:09:57 +0200

Hi all,

i have a problem marshalling an attribute, that helds a list like the xml
schema below.

<complexType name="Header">
        <attribute name="error" type="errorType" use="optional"/>
</complexType>
<simpleType name="ErrorType">
        <list itemType="ErrorNrType"/>
</simpleType>
<simpleType name="ErrorNrType">
        <restriction base="string">
                <length value="9"/>
                <pattern value="[A-Z]{2}([0-9]|[A-Z]){7}"/>
        </restriction>
</simpleType>

Everything went fine, if the list helds data. If the attribute helds no
data, the output of the marshaller looks like

<myElement error=""/>

But this will lead to an error during validation. Looking at the generated
code by the xjc, i have seen, that is is impossible to set the list to NULL.
Even the unset method will be no help, because the attribute will be set to
an empty list, if unset() will be called.
"error" is an optional attribute. Is it possible that the marshaller will
NOT print the attribute if the list contains no data? If not, want could be
done to get a valid output (it is not possible to change the schema)?

Since



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe_at_jaxb.dev.java.net
For additional commands, e-mail: users-help_at_jaxb.dev.java.net