DocumentFactory df = DocumentFactory.getInstance();
Document doc = df.createDocument();
int count = 1;
for(int i=0; i < list.size(); i++)
{
MenuVO menu = (MenuVO) list.get(i);
if(menu.getMenuName().equals(TAG_ROOT))
{
Element elem = doc.addElement(menu.getMenuName());
elem = elem.addAttribute(ATTR_ID, ATTR_VAL_ID + 0);
elem = elem.addAttribute(ATTR_HREF, menu.getHyperlink());
map.put(menu.getMenuId(), elem);
count = count + 1;
}
else
{
if(menu.getMenuName().equalsIgnoreCase(FULL_MENU))
{
count = count + 1;
continue;
}
Element elem = ((Element) map.get(menu.getParentMenuId()));
elem = elem.addElement(menu.getTagName());
elem = elem.addAttribute(ATTR_ID, ATTR_VAL_ID + menu.getMenuId() + (menu.getLeaf().equalsIgnoreCase(VALUE_NO) ? VALUE_CLOSED : ""));
elem = elem.addAttribute(ATTR_NAME, menu.getMenuName());
elem = elem.addAttribute(ATTR_Q_NAME, menu.getQuickMenuName());
elem = elem.addAttribute(ATTR_HREF, menu.getHyperlink());
if(menu.getLeaf().equalsIgnoreCase(VALUE_YES))
{
elem = elem.addAttribute(ATTR_LEAF, VALUE_TRUE);
}
else if(menu.getLeaf().equalsIgnoreCase(VALUE_NO))
{
elem = elem.addAttribute(ATTR_LEAF, VALUE_FALSE);
}
elem = elem.addAttribute(ATTR_TARGET, menu.getTarget());
if(menu.getPopup().equalsIgnoreCase(VALUE_YES))
{
elem = elem.addAttribute(ATTR_POP, VALUE_TRUE);
}
else if(menu.getPopup().equalsIgnoreCase(VALUE_NO))
{
elem = elem.addAttribute(ATTR_POP, VALUE_FALSE);
}
if(menu !=null && menu.getEnabled().equalsIgnoreCase(VALUE_NO))
{
elem = elem.addAttribute(ATTR_ENABLED, VALUE_FALSE);
}
else
{
elem = elem.addAttribute(ATTR_ENABLED, VALUE_TRUE);
}
map.put(menu.getMenuId(), elem);
count = count + 1;
}
}