commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Portabella Clotet <da...@portabella.name>
Subject Use the mapping file to specify how to serialize a hashmap into a XML
Date Mon, 07 Sep 2009 11:19:58 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message