// Field name local to the loop
String fieldName = fields[i].getName();
// Field length local to the loop
int fieldLength = fields[i].getLength();
StringFunctionExecutor stringFunctionExecutor = fields[i].getStringFunctionExecutor();
if(!fields[i].ignore()) {
if(indent) {
contentHandler.characters(INDENT_LF, 0, 1);
contentHandler.characters(INDENT_2, 0, 2);
}
// Check that there are enough characters in the string
boolean truncated = fieldLengthTotal + fieldLength > flRecord.length();
AttributesImpl recordAttrs = EMPTY_ATTRIBS;
//If truncated then set the truncated attribute
if(truncated) {
recordAttrs = new AttributesImpl();
recordAttrs.addAttribute(XMLConstants.NULL_NS_URI, truncatedAttributeName, truncatedAttributeName, "xs:boolean", Boolean.TRUE.toString());
}
contentHandler.startElement(XMLConstants.NULL_NS_URI, fieldName, StringUtils.EMPTY, recordAttrs);
// If not truncated then set the element data
if(!truncated) {
if(stringFunctionExecutor == null) {
contentHandler.characters(recordChars, fieldLengthTotal, fieldLength);
} else {
String value = flRecord.substring(fieldLengthTotal, fieldLengthTotal + fieldLength);
value = stringFunctionExecutor.execute(value);
contentHandler.characters(value.toCharArray(), 0, value.length());
}
}