Details
Description
The issue appears when getting castor to marshall / unmarshall a HashMap with
xml binding provided in the castor mapping file and schema validation.
The castor mapping has been specified to provide the key/value pair
as named attributes, and a schema defined to expect this format.
e.g. as shown in the hand-coded marshalled data:
<CountryCode isoNumeric='266' name='Gabon'/>
When castor itself marshals the data, it appears to disregard the supplementary
mapping specified in the castor map and instead writes out the map with key and
value element pairs:
<CountryCode>
<key>270</key>
<value>Gambia</value>
</CountryCode>
As the provided schema (and castor map) has been told to expect attributes
called isoNumeric and name, this fails when the castor marshalled data
is unmarshalled because the xml fails against the schema.
The castor mapping for these attributes is specified as:
<field name='Translator' type='java.util.HashMap' collection='map'>
<bind-xml name='CountryCode'>
<class name='org.exolab.castor.mapping.MapItem'>
<field name='key' type='java.lang.String'>
<bind-xml name='isoNumeric' node='attribute'/>
</field>
<field name='value' type='java.lang.String'>
<bind-xml name='name' node='attribute'/>
</field>
</class>
</bind-xml>
</field>
Activity
| Field | Original Value | New Value |
|---|---|---|
| Assignee | Werner Guttmann [ wguttmn ] |
| Attachment | MappingDto.java [ 23122 ] |
| Attachment | MappingCastorMap.xml [ 23124 ] |
| Attachment | country.xsd [ 23125 ] |
| Attachment | patch.c1582.20060927.txt [ 23130 ] |
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Resolution | Won't Fix [ 2 ] | |
| Fix Version/s | 1.0.4 [ 12888 ] |
| Status | Resolved [ 5 ] | Closed [ 6 ] |
Graham, can you please attach all relevant files, e.g. mapping file, MappingDto.Java, etc.. ?