return selectionList;
}
private SelectionList buildStaticList(Element selectionListElement, Datatype datatype) throws Exception {
StaticSelectionList selectionList = new StaticSelectionList(datatype);
Convertor convertor = null;
Convertor.FormatCache formatCache = new DefaultFormatCache();
NodeList children = selectionListElement.getChildNodes();
for (int i = 0; children.item(i) != null; i++) {
Node node = children.item(i);
if (convertor == null && node instanceof Element && Constants.WD_NS.equals(node.getNamespaceURI()) && "convertor".equals(node.getLocalName())) {
Element convertorConfigElement = (Element)node;
try {
convertor = datatype.getBuilder().buildConvertor(convertorConfigElement);
} catch (Exception e) {
throw new SAXException("Error building convertor from convertor configuration embedded in selection list XML.", e);
}
} else if (node instanceof Element && Constants.WD_NS.equals(node.getNamespaceURI()) && "item".equals(node.getLocalName())) {
if (convertor == null) {
convertor = datatype.getConvertor();
}
Element element = (Element)node;
String stringValue = element.getAttribute("value");
Object value;
if ("".equals(stringValue)) {
// Empty value translates into the null object
value = null;
} else {
value = convertor.convertFromString(stringValue, Locale.US, formatCache);
if (value == null) {
throw new Exception("Could not convert the value \"" + stringValue +
"\" to the type " + datatype.getDescriptiveName() +
", defined at " + DomHelper.getLocation(element));
}