if (attrs.isEmpty()) {
return Collections.emptyList();
} else {
List<Attribute> result = Lists.newArrayList();
for (Attribute attr : attrs) {
AttributeValidator attrValidator =
elementValidator.getAttributeValidator(attr.getName());
if (attrValidator == null) {
alertSink.add(new UnknownAttributeError(forNode, attr));
} else {
Expression attrValue = attr.getValue();
if (attrValue instanceof StringConstant) {
String value = ((StringConstant) attrValue).evaluate();
if (!attrValidator.isValidValue(value)) {
alertSink.add(new InvalidAttributeValueError(attr));
}
}
// if the attribute validator indicates an inner content type then
// set this on the attribute
String innerContentTypeString = attrValidator.getContentType();
if (innerContentTypeString != null) {
Schema innerSchema = schemaFactory.fromContentTypeName(innerContentTypeString);
attr = attr.withInnerSchema(innerSchema);
}