You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by David Portabella Clotet <da...@portabella.name> on 2009/09/07 13:19:58 UTC

Use the mapping file to specify how to serialize a hashmap into a XML

Hello,

We use Apache Betwixt to serialize a Java object into XML using a mapping
file.

Betwixt can also serialize HashMaps, but it uses a predefined entry
key/value schema.

For instance, for
HashMap person = new HashMap();
person.put("name", "John");
person.put("bibliography", "John started his...");

it will produce:
<entry>
  <key>name</key>
  <value>John</value>
</entry>
<entry>
  <key>bibliography</key>
  <value>John started his...</value>
</entry>


Is it possible to use the same mapping file to specify how the hashmap
should be serialized?
For instance, using this schema,
<?xml version="1.0" encoding="UTF-8" ?>
<info primitiveTypes="attribute">
  <element name='person'>
    <attribute name='name' property='name'/>
    <element name='bibliography' property='bibliography'/>
  </element>
</info>

Betwixt would serialize the previous hashmap as:
<person name="John">
  <bibliography>John started his...</bibilography>
</person>


Is that possible? how?
or, do you plan to implement such a feature?


Regards,
David