retValue = Boolean.FALSE;
} else if (value.equals(SchemaSymbols.ATTVAL_TRUE) ||
value.equals(SchemaSymbols.ATTVAL_TRUE_1)) {
retValue = Boolean.TRUE;
} else {
throw new InvalidDatatypeValueException("the value '"+value+"' is not a valid boolean");
}
break;
case DT_NONNEGINT:
try {
retValue = fXIntPool.getXInt(Integer.parseInt(value));
} catch (NumberFormatException e) {
throw new InvalidDatatypeValueException("the value '"+value+"' is not a valid nonNegativeInteger");
}
if (((XInt)retValue).intValue() < 0)
throw new InvalidDatatypeValueException("the value '"+value+"' is not a valid nonNegativeInteger");
break;
case DT_BLOCK:
// block = (#all | List of (substitution | extension | restriction | list | union))
choice = 0;
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
SchemaSymbols.UNION;
}
else {
StringTokenizer t = new StringTokenizer (value, " ");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
if (token.equals (SchemaSymbols.ATTVAL_SUBSTITUTION)) {
choice |= SchemaSymbols.SUBSTITUTION;
}
else if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
choice |= SchemaSymbols.EXTENSION;
}
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
choice |= SchemaSymbols.RESTRICTION;
}
else if (token.equals (SchemaSymbols.ATTVAL_LIST)) {
choice |= SchemaSymbols.LIST;
}
else if (token.equals (SchemaSymbols.ATTVAL_UNION)) {
choice |= SchemaSymbols.RESTRICTION;
}
else {
throw new InvalidDatatypeValueException("the value '"+value+"' must match (#all | List of (substitution | extension | restriction | list | union))");
}
}
}
retValue = fXIntPool.getXInt(choice);
break;
case DT_BLOCK1:
case DT_FINAL:
// block = (#all | List of (extension | restriction))
// final = (#all | List of (extension | restriction))
choice = 0;
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
//choice = SchemaSymbols.EXTENSION|SchemaSymbols.RESTRICTION;
// REVISIT: if #all, then make the result the combination of
// everything: substitution/externsion/restriction/list/union.
// would this be a problem?
// the reason doing so is that when final/blockFinal on <schema>
// is #all, it's not always the same as the conbination of those
// values allowed by final/blockFinal.
// for example, finalDefault="#all" is not always the same as
// finalDefault="extension restriction".
// if finalDefault="#all", final on any simple type would be
// "extension restriction list union".
choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
SchemaSymbols.UNION;
}
else {
StringTokenizer t = new StringTokenizer (value, " ");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
if (token.equals (SchemaSymbols.ATTVAL_EXTENSION)) {
choice |= SchemaSymbols.EXTENSION;
}
else if (token.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
choice |= SchemaSymbols.RESTRICTION;
}
else {
throw new InvalidDatatypeValueException("the value '"+value+"' must match (#all | List of (extension | restriction))");
}
}
}
retValue = fXIntPool.getXInt(choice);
break;
case DT_FINAL1:
// final = (#all | (list | union | restriction))
choice = 0;
if (value.equals (SchemaSymbols.ATTVAL_POUNDALL)) {
//choice = SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
// SchemaSymbols.UNION;
// REVISIT: if #all, then make the result the combination of
// everything: substitution/externsion/restriction/list/union.
// would this be a problem?
// same reason as above DT_BLOCK1/DT_FINAL
choice = SchemaSymbols.SUBSTITUTION|SchemaSymbols.EXTENSION|
SchemaSymbols.RESTRICTION|SchemaSymbols.LIST|
SchemaSymbols.UNION;
}
else if (value.equals (SchemaSymbols.ATTVAL_LIST)) {
choice = SchemaSymbols.LIST;
}
else if (value.equals (SchemaSymbols.ATTVAL_UNION)) {
choice = SchemaSymbols.UNION;
}
else if (value.equals (SchemaSymbols.ATTVAL_RESTRICTION)) {
choice = SchemaSymbols.RESTRICTION;
}
else {
throw new InvalidDatatypeValueException("the value '"+value+"' must match (#all | (list | union | restriction))");
}
retValue = fXIntPool.getXInt(choice);
break;
case DT_FORM:
// form = (qualified | unqualified)
if (value.equals (SchemaSymbols.ATTVAL_QUALIFIED))
retValue = INT_QUALIFIED;
else if (value.equals (SchemaSymbols.ATTVAL_UNQUALIFIED))
retValue = INT_UNQUALIFIED;
else
throw new InvalidDatatypeValueException("the value '"+value+"' must match (qualified | unqualified)");
break;
case DT_MAXOCCURS:
// maxOccurs = (nonNegativeInteger | unbounded)
if (value.equals(SchemaSymbols.ATTVAL_UNBOUNDED)) {
retValue = INT_UNBOUNDED;
} else {
try {
retValue = validate(attr, value, DT_NONNEGINT, schemaDoc);
} catch (NumberFormatException e) {
throw new InvalidDatatypeValueException("the value '"+value+"' must match (nonNegativeInteger | unbounded)");
}
}
break;
case DT_MAXOCCURS1:
// maxOccurs = 1
if (value.equals("1"))
retValue = fXIntPool.getXInt(1);
else
throw new InvalidDatatypeValueException("the value '"+value+"' must be '1'");
break;
case DT_MEMBERTYPES:
// memberTypes = List of QName
memberType = new Vector();
try {
StringTokenizer t = new StringTokenizer (value, " ");
while (t.hasMoreTokens()) {
String token = t.nextToken ();
QName qname = (QName)fExtraDVs[DT_QNAME].validate(token, schemaDoc.fValidationContext, null);
// kludge to handle chameleon includes/redefines...
if(qname.prefix == fSchemaHandler.EMPTY_STRING && qname.uri == null && schemaDoc.fIsChameleonSchema)
qname.uri = schemaDoc.fTargetNamespace;
memberType.addElement(qname);
}
retValue = memberType;
}
catch (InvalidDatatypeValueException ide) {
throw new InvalidDatatypeValueException("the value '"+value+"' must match (List of QName)");
}
break;
case DT_MINOCCURS1:
// minOccurs = (0 | 1)
if (value.equals("0"))
retValue = fXIntPool.getXInt(0);
else if (value.equals("1"))
retValue = fXIntPool.getXInt(1);
else
throw new InvalidDatatypeValueException("the value '"+value+"' must be '0' or '1'");
break;
case DT_NAMESPACE:
// namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )
XSWildcardDecl wildcard = null;
if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDANY)) {
// ##any
wildcard = WC_ANY;
} else if (value.equals(SchemaSymbols.ATTVAL_TWOPOUNDOTHER)) {
// ##other
wildcard = new XSWildcardDecl();
wildcard.fType = XSWildcardDecl.WILDCARD_OTHER;
wildcard.fNamespaceList = new String[2];
wildcard.fNamespaceList[0] = schemaDoc.fTargetNamespace;
wildcard.fNamespaceList[1] = null;
} else {
// list
wildcard = new XSWildcardDecl();
wildcard.fType = XSWildcardDecl.WILDCARD_LIST;
// tokenize
StringTokenizer tokens = new StringTokenizer(value);
String[] namespaceList = new String[tokens.countTokens()];
int nsNum = 0;
String token;
String tempNamespace;
try {
while (tokens.hasMoreTokens()) {
token = tokens.nextToken();
if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDLOCAL)) {
tempNamespace = null;
} else if (token.equals(SchemaSymbols.ATTVAL_TWOPOUNDTARGETNS)) {
tempNamespace = schemaDoc.fTargetNamespace;
} else {
// we have found namespace URI here
// need to add it to the symbol table
fExtraDVs[DT_ANYURI].validate(token, schemaDoc.fValidationContext, null);
tempNamespace = fSymbolTable.addSymbol(token);
}
//check for duplicate namespaces in the list
int j = 0;
for (; j < nsNum; j++) {
if (tempNamespace == namespaceList[j])
break;
}
if (j == nsNum) {
// this means traversed whole for loop
// i.e. not a duplicate namespace
namespaceList[nsNum++] = tempNamespace;
}
}
} catch (InvalidDatatypeValueException ide) {
throw new InvalidDatatypeValueException("the value '"+value+"' must match ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local)) )");
}
// resize the array, so there is no empty entry
if (nsNum == namespaceList.length) {
wildcard.fNamespaceList = namespaceList;
} else {
wildcard.fNamespaceList = new String[nsNum];
System.arraycopy(namespaceList, 0, wildcard.fNamespaceList, 0, nsNum);
}
}
retValue = wildcard;
break;
case DT_PROCESSCONTENTS:
// processContents = (lax | skip | strict)
if (value.equals (SchemaSymbols.ATTVAL_STRICT))
retValue = INT_ANY_STRICT;
else if (value.equals (SchemaSymbols.ATTVAL_LAX))
retValue = INT_ANY_LAX;
else if (value.equals (SchemaSymbols.ATTVAL_SKIP))
retValue = INT_ANY_SKIP;
else
throw new InvalidDatatypeValueException("the value '"+value+"' must match (lax | skip | strict)");
break;
case DT_PUBLIC:
// public = A public identifier, per ISO 8879
// REVISIT: how to validate "public"???
fExtraDVs[DT_TOKEN].validate(value, schemaDoc.fValidationContext, null);
break;
case DT_USE:
// use = (optional | prohibited | required)
if (value.equals (SchemaSymbols.ATTVAL_OPTIONAL))
retValue = INT_USE_OPTIONAL;
else if (value.equals (SchemaSymbols.ATTVAL_REQUIRED))
retValue = INT_USE_REQUIRED;
else if (value.equals (SchemaSymbols.ATTVAL_PROHIBITED))
retValue = INT_USE_PROHIBITED;
else
throw new InvalidDatatypeValueException("the value '"+value+"' must match (optional | prohibited | required)");
break;
case DT_WHITESPACE:
// value = preserve | replace | collapse
if (value.equals (SchemaSymbols.ATTVAL_PRESERVE))
retValue = INT_WS_PRESERVE;
else if (value.equals (SchemaSymbols.ATTVAL_REPLACE))
retValue = INT_WS_REPLACE;
else if (value.equals (SchemaSymbols.ATTVAL_COLLAPSE))
retValue = INT_WS_COLLAPSE;
else
throw new InvalidDatatypeValueException("the value '"+value+"' must match (preserve | replace | collapse)");
break;
}
return retValue;
}