xroot = xmlNewNode (NULL, (xmlChar *)"element");
- xnode = xmlNewNode (NULL, (xmlChar *)"name");
- xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_name (element));
- xmlAddChild (xroot, xnode);
+ if (zak_form_element_get_name (element) != NULL)
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"name");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_name (element));
+ xmlAddChild (xroot, xnode);
+ }
- xnode = xmlNewNode (NULL, (xmlChar *)"long-name");
- xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_long_name (element));
- xmlAddChild (xroot, xnode);
+ if (zak_form_element_get_long_name (element) != NULL)
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"long-name");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_long_name (element));
+ xmlAddChild (xroot, xnode);
+ }
- xnode = xmlNewNode (NULL, (xmlChar *)"is-key");
- xmlNodeSetContent (xnode, zak_form_element_get_is_key (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
- xmlAddChild (xroot, xnode);
+ if (zak_form_element_get_is_key (element))
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"is-key");
+ xmlNodeSetContent (xnode, zak_form_element_get_is_key (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+ }
- xnode = xmlNewNode (NULL, (xmlChar *)"type");
- xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_provider_type (element));
- xmlAddChild (xroot, xnode);
+ if (zak_form_element_get_provider_type (element) != NULL)
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"type");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_provider_type (element));
+ xmlAddChild (xroot, xnode);
+ }
- xnode = xmlNewNode (NULL, (xmlChar *)"default-value");
- xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_default_value (element));
- xmlAddChild (xroot, xnode);
+ if (zak_form_element_get_default_value (element) != NULL
+ && g_strcmp0 (zak_form_element_get_default_value (element), "") != 0)
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"default-value");
+ xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_default_value (element));
+ xmlAddChild (xroot, xnode);
+ }
- xnode = xmlNewNode (NULL, (xmlChar *)"format");
- xmlNodeSetContent (xnode, (xmlChar *)zak_form_element_get_format (element));
- xmlAddChild (xroot, xnode);
+ GHashTable *ht;
- xnode = xmlNewNode (NULL, (xmlChar *)"visible");
- xmlNodeSetContent (xnode, zak_form_element_get_visible (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
- xmlAddChild (xroot, xnode);
+ ht = zak_form_element_get_format (element);
+ if (ht != NULL)
+ {
+ GHashTableIter iter;
+ gpointer key;
+ gpointer value;
- xnode = xmlNewNode (NULL, (xmlChar *)"editable");
- xmlNodeSetContent (xnode, zak_form_element_get_editable (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
- xmlAddChild (xroot, xnode);
+ xnode = xmlNewNode (NULL, (xmlChar *)"format");
- xnode = xmlNewNode (NULL, (xmlChar *)"to-load");
- xmlNodeSetContent (xnode, zak_form_element_get_to_load (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
- xmlAddChild (xroot, xnode);
+ g_hash_table_iter_init (&iter, ht);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ if (g_strcmp0 (key, "content") == 0)
+ {
+ xmlNodeSetContent (xnode, (xmlChar *)value);
+ }
+ else
+ {
+ xmlSetProp (xnode, key, value);
+ }
+ }
+
+ xmlAddChild (xroot, xnode);
+ }
- xnode = xmlNewNode (NULL, (xmlChar *)"to-save");
- xmlNodeSetContent (xnode, zak_form_element_get_to_save (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
- xmlAddChild (xroot, xnode);
+ if (!zak_form_element_get_visible (element))
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"visible");
+ xmlNodeSetContent (xnode, zak_form_element_get_visible (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+ }
+
+ if (!zak_form_element_get_editable (element))
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"editable");
+ xmlNodeSetContent (xnode, zak_form_element_get_editable (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+ }
+
+ if (!zak_form_element_get_to_load (element))
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"to-load");
+ xmlNodeSetContent (xnode, zak_form_element_get_to_load (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+ }
+
+ if (!zak_form_element_get_to_save (element))
+ {
+ xnode = xmlNewNode (NULL, (xmlChar *)"to-save");
+ xmlNodeSetContent (xnode, zak_form_element_get_to_save (element) ? (xmlChar *)"TRUE" : (xmlChar *)"FALSE");
+ xmlAddChild (xroot, xnode);
+ }
if (ZAK_FORM_ELEMENT_GET_CLASS (element)->get_xml != NULL)
{