* data form is the result of the {@link #encode(Object)} method.
*
* @param fields list of <variable,value> to be added as a new item.
*/
public void addItemFields(Map<String,Object> fields) {
Element item = element.addElement("item");
// Add a field element to the item element for each row in fields
for (String var : fields.keySet()) {
Element field = item.addElement("field");
field.addAttribute("var", var);
Object value = fields.get(var);
if (value instanceof Collection) {
// Add a value element for each entry in the collection
for (Iterator it = ((Collection) value).iterator(); it.hasNext();) {
field.addElement("value").setText(encode(it.next()));
}
}
else {
field.addElement("value").setText(encode(value));
}
}
}