Pattern regex = null;
Expression constructor = null;
boolean hasConstructorFlag = false;
String content = attrMap.getOptional("content", null);
Type defaultType = null;
boolean consumesContent = content != null;
if (consumesContent) {
if (!"*".equals(content)) {
alertSink.add(new InvalidAttributeValueError(attrMap.getAttribute("content")));
}
if (rootSchema != null) {
defaultType = new ContentType(node.getSourcePosition(),
node.getDisplayName(),
rootSchema);
}
}
Type type = createType(node, attrMap, true, defaultType);
if (type == null) {
// Bail out without trying to construct Parameter.
return null;
}
if (consumesContent && !type.isContent()) {
alertSink.add(new ContentTypeExpectedAlert(node.getSourcePosition(),
node.getDisplayName(),
"when content='*' is set."));
type = defaultType;
}
if (type.takesDefaultParam()) {
defaultValue = attrMap.getOptionalExprValue("default", null);
hasDefaultFlag = attrMap.getBooleanValue("has-default");
}
if (type.takesRegexParam()) {
String regexStr = attrMap.getOptional("regex", null);
if (regexStr != null) {
try {
regex = Pattern.compile(regexStr);
} catch (PatternSyntaxException e) {
alertSink.add(new BadRegexError(node, e.getPattern()));
}
}
} else {
regex = type.getPattern(name);
}
if (type.takesConstructorParam()) {
constructor = attrMap.getOptionalExprValue("constructor", null);
hasConstructorFlag = attrMap.getBooleanValue("has-constructor");
}
SpaceOperatorSet spaceOperators = getSpaceOperators(attrMap);