Castor version used: castor-1.0.2.jar Castor mapping and schema used are coded in the unit test. 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: 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: 270 Gambia 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: In the unit test provided, testUnmarshall() succeeds as the xml data was hand coded and conforms to the schema and mapping. The testMarshall() case fails as the marshalled code produces key/value elements which throw an exception when unmarshalled as this does not reflect the format in the mapping file and schema.