* returns the compiled form of the value
* The parameter value could be either a String or a ValidatedInfo object
*/
public static Object ElementDefaultValidImmediate(XSTypeDefinition type, String value, ValidationContext context, ValidatedInfo vinfo) {
XSSimpleType dv = null;
// e-props-correct
// For a string to be a valid default with respect to a type definition the appropriate case among the following must be true:
// 1 If the type definition is a simple type definition, then the string must be valid with respect to that definition as defined by String Valid (3.14.4).
if (type.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE) {
dv = (XSSimpleType)type;
}
// 2 If the type definition is a complex type definition, then all of the following must be true:
else {
// 2.1 its {content type} must be a simple type definition or mixed.
XSComplexTypeDecl ctype = (XSComplexTypeDecl)type;
// 2.2 The appropriate case among the following must be true:
// 2.2.1 If the {content type} is a simple type definition, then the string must be valid with respect to that simple type definition as defined by String Valid (3.14.4).
if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_SIMPLE) {
dv = ctype.fXSSimpleType;
}
// 2.2.2 If the {content type} is mixed, then the {content type}'s particle must be emptiable as defined by Particle Emptiable (3.9.6).
else if (ctype.fContentType == XSComplexTypeDecl.CONTENTTYPE_MIXED) {
if (!((XSParticleDecl)ctype.getParticle()).emptiable())
return null;
}
else {
return null;
}
}
// get the simple type declaration, and validate
Object actualValue = null;
if (dv == null) {
// complex type with mixed. to make sure that we store correct
// information in vinfo and return the correct value, we use
// "string" type for validation
dv = STRING_TYPE;
}
try {
// validate the original lexical rep, and set the actual value
actualValue = dv.validate(value, context, vinfo);
// validate the canonical lexical rep
if (vinfo != null)
actualValue = dv.validate(vinfo.stringValue(), context, vinfo);
} catch (InvalidDatatypeValueException ide) {
return null;
}
return actualValue;