If I have a castor mapping file like the following:

<field
name="Tiers" type="com.example.Tier" collection="collection" container="false">
   <bind-xml name="Tiers" node="element"/>
</field>
</class>
<class name="com.example.Tier">
   <map-to xml="Tier">
   <field name="minimumDollarAmount" type="java.lang.Double">
      <bind-xml name="MinimumDollarAmount" node="element"/>
   </field>
   <field name="code" type="java.lang.String">
      <bind-xml name="code" node="element"/>
   </field>
</class>

Then if my java class contains a List<Tier> tiers = null then castor will
generate an XML tag like
<Tier /> even though it shouldn't generate anything because the collection
was null.

My XSD defines that <Tiers> has minOccurs=0, but if <Tiers> does exist then
it must contain at least 1 element <Tier> or the XML is invalid.


This is valid XML:

<Tiers>

   <Tier/>

   <Tier/>

</Tiers>


This is invalid XML:

<Tier/>

I've created JIRA related to this issue since it's stopping us from using
castor at the moment.
http://jira.codehaus.org/browse/CASTOR-2712

Reply via email to