String unparsedValue = attributes.getValue("value");
if (unparsedValue == null || "".equals(unparsedValue)) {
// Empty (or null) value translates into the empty string
currentValueAsString = "";
} else {
ConversionResult conversionResult = convertor.convertFromString(unparsedValue, locale, fromFormatCache);
if (!conversionResult.isSuccessful()) {
throw new SAXException("Could not interpret the following value: \"" + unparsedValue + "\".");
}
currentValue = conversionResult.getResult();
currentValueAsString = datatype.getConvertor().convertToString(currentValue, locale, toFormatCache);
}
AttributesImpl attrs = new AttributesImpl();
attrs.addCDATAAttribute("value", currentValueAsString);
super.startElement(Constants.INSTANCE_NS, localName, Constants.INSTANCE_PREFIX_COLON + localName, attrs);