// Validate that the element has content that is non-whitespace
Iterator contents = element.getContent().iterator();
if (!contents.hasNext()) {
ErrorDetails details = new ErrorDetails(element, new XPath(element),
null, FaultTypes.WHITESPACE, null, null);
errorReporter.reportError(details);
} else {
Text text = (Text) contents.next();
String value = text.getText();
if (value.length() == 0) {
ErrorDetails details = new ErrorDetails(element, new XPath(element),
null, FaultTypes.WHITESPACE, null, null);
errorReporter.reportError(details);
} else {
// Ensure that the value is a number that is comprized only
// of digits and is either 6 or 8 digits in length
boolean valid = value.length() == 6 || value.length() == 8;
if (valid) {
for (int i = 0; i < value.length() && valid; i++) {
valid = Character.isDigit(value.charAt(i));
}
}
if (!valid) {
ErrorDetails details = new ErrorDetails(
element, new XPath(element), null, INVALID_TAC_NUMBER,
null, null);
errorReporter.reportError(details);
}
}