commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Pete Ford (JIRA)" <>
Subject [jira] Created: (BETWIXT-63) Writing Map key/value pairs produces incorrect XML tags
Date Fri, 29 Aug 2008 16:16:55 GMT
Writing Map key/value pairs produces incorrect XML tags

                 Key: BETWIXT-63
             Project: Commons Betwixt
          Issue Type: Bug
         Environment: Windows XP, Java 1.6.0_04, Eclipse
            Reporter: Pete Ford
            Priority: Minor

Using download version 0.8.

A Map field within a Javabean produces XML containing Key and Value tags by default (i.e.
without a .betwixt file):


private Map<String, String> details = new TreeMap<String, String>();

Example XML output:


When reading the generated XML back into Betwixt to reconstruct the bean, the map is not populated.
It appears that when reading, Betwixt looks for the tags <key> and <value> (uncapitalized).
Filtering the XML to replace <Key> with <key>, etc., before reading in fixes the
problem. It would appear that Betwixt should be generating "<key>" and "<value>"
when writing (to match the case of the enclosing "<entry>" tag). Possibly this is something
to do with using Capitalized names (see the code below - it sets up a CapitalizedNamesMapper
for element names).

The code that configures the writer in this case is:

        StringWriter sw = new StringWriter();
        BeanWriter writer = new BeanWriter(sw);

        // set a custom name mapper for attributes
                .setAttributeNameMapper(new HyphenatedNameMapper());

        // set a custom name mapper for elements
                .setElementNameMapper(new CapitalizeNameMapper());

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message