SimpleType schemaType = getSchemaType();
int validationAction = getValidationAction();
if (schemaType != null) {
// test whether the value actually conforms to the given type
try {
ValidationFailure err = schemaType.validateContent(
value, DummyNamespaceResolver.getInstance(), context.getConfiguration().getNameChecker());
if (err != null) {
ValidationException ve = new ValidationException(
"Attribute value " + Err.wrap(value, Err.VALUE) +
" does not match the required type " +
schemaType.getDescription() + ". " +
err.getMessage());
ve.setErrorCode("XTTE1540");
throw ve;
}
} catch (UnresolvedReferenceException ure) {
throw new ValidationException(ure);
}
} else if (validationAction== Validation.STRICT ||
validationAction==Validation.LAX) {
try {
ann = context.getConfiguration().validateAttribute(nameCode, value, validationAction);
} catch (ValidationException e) {
XPathException err = XPathException.makeXPathException(e);
err.maybeSetErrorCode((validationAction==Validation.STRICT ? "XTTE1510" : "XTTE1515"));
err.setXPathContext(context);
err.maybeSetLocation(this);
err.setIsTypeError(true);
throw err;
}
}
if ((nameCode & NamePool.FP_MASK) == StandardNames.XML_ID) {
value = Whitespace.collapseWhitespace(value);