try {
contentHandler.startElement(Constants.INSTANCE_NS, SELECTION_LIST_EL, Constants.INSTANCE_PREFIX_COLON + SELECTION_LIST_EL, XMLUtils.EMPTY_ATTRIBUTES);
Field fields[] = clazz.getDeclaredFields();
// Create void element
if (nullable) {
AttributesImpl voidAttrs = new AttributesImpl();
voidAttrs.addCDATAAttribute("value", "");
contentHandler.startElement(Constants.INSTANCE_NS, ITEM_EL, Constants.INSTANCE_PREFIX_COLON + ITEM_EL, voidAttrs);
contentHandler.endElement(Constants.INSTANCE_NS, ITEM_EL, Constants.INSTANCE_PREFIX_COLON + ITEM_EL);
}
for (int i = 0 ; i < fields.length ; ++i) {
int mods = fields[i].getModifiers();
if (Modifier.isPublic(mods) && Modifier.isStatic(mods)
&& Modifier.isFinal(mods) && fields[i].get(null).getClass().equals(clazz)) {
String stringValue = clazz.getName() + "." + fields[i].getName();
// Output this item
AttributesImpl itemAttrs = new AttributesImpl();
itemAttrs.addCDATAAttribute("value", stringValue);
contentHandler.startElement(Constants.INSTANCE_NS, ITEM_EL, Constants.INSTANCE_PREFIX_COLON + ITEM_EL, itemAttrs);
contentHandler.startElement(Constants.INSTANCE_NS, LABEL_EL, Constants.INSTANCE_PREFIX_COLON + LABEL_EL, XMLUtils.EMPTY_ATTRIBUTES);
// TODO: make i18n element optional
contentHandler.startElement(I18N_NS, TEXT_EL, I18N_PREFIX_COLON + TEXT_EL, XMLUtils.EMPTY_ATTRIBUTES);
contentHandler.characters(stringValue.toCharArray(), 0, stringValue.length());