} else
newSimpleTypeName = fStringPool.addSymbol( nameProperty );
int basetype;
DatatypeValidator baseValidator = null;
if( baseTypeQNameProperty!= null ) {
basetype = fStringPool.addSymbol( baseTypeQNameProperty );
String prefix = "";
String localpart = baseTypeQNameProperty;
int colonptr = baseTypeQNameProperty.indexOf(":");
if ( colonptr > 0) {
prefix = baseTypeQNameProperty.substring(0,colonptr);
localpart = baseTypeQNameProperty.substring(colonptr+1);
}
String uri = resolvePrefixToURI(prefix);
baseValidator = getDatatypeValidator(uri, localpart);
if (baseValidator == null) {
Element baseTypeNode = getTopLevelComponentByName(SchemaSymbols.ELT_SIMPLETYPE, localpart);
if (baseTypeNode != null) {
traverseSimpleTypeDecl( baseTypeNode );
baseValidator = getDatatypeValidator(uri, localpart);
if (baseValidator == null) {
reportSchemaError(SchemaMessageProvider.UnknownBaseDatatype,
new Object [] { simpleTypeDecl.getAttribute( SchemaSymbols.ATT_BASE ),
simpleTypeDecl.getAttribute(SchemaSymbols.ATT_NAME) });
return -1;
//reportGenericSchemaError("Base type could not be found : " + baseTypeQNameProperty);
}
}
else {
reportSchemaError(SchemaMessageProvider.UnknownBaseDatatype,
new Object [] { simpleTypeDecl.getAttribute( SchemaSymbols.ATT_BASE ),
simpleTypeDecl.getAttribute(SchemaSymbols.ATT_NAME) });
return -1;
//reportGenericSchemaError("Base type could not be found : " + baseTypeQNameProperty);
}
}
}
// Any Children if so then check Content otherwise bail out
Element content = XUtil.getFirstChildElement( simpleTypeDecl );
int numFacets = 0;
Hashtable facetData = null;
if( content != null ) {
//Content follows: ( annotation? , facets* )
//annotation ? ( 0 or 1 )
if( content.getLocalName().equals( SchemaSymbols.ELT_ANNOTATION ) ){
traverseAnnotationDecl( content );
content = XUtil.getNextSiblingElement(content);
}
//TODO: If content is annotation again should raise validation error
// if( content.getLocalName().equal( SchemaSymbols.ELT_ANNOTATIO ) {
// throw ValidationException(); }
//
//facets * ( 0 or more )
int numEnumerationLiterals = 0;
facetData = new Hashtable();
Vector enumData = new Vector();
while (content != null) {
if (content.getNodeType() == Node.ELEMENT_NODE) {
Element facetElt = (Element) content;
numFacets++;
if (facetElt.getLocalName().equals(SchemaSymbols.ELT_ENUMERATION)) {
numEnumerationLiterals++;
String enumVal = facetElt.getAttribute(SchemaSymbols.ATT_VALUE);
enumData.addElement(enumVal);
//Enumerations can have annotations ? ( 0 | 1 )
Element enumContent = XUtil.getFirstChildElement( facetElt );
if( enumContent != null && enumContent != null && enumContent.getLocalName().equals( SchemaSymbols.ELT_ANNOTATION ) ){
traverseAnnotationDecl( content );
}
//TODO: If enumContent is encounter again should raise validation error
// enumContent.getNextSibling();
// if( enumContent.getLocalName().equal( SchemaSymbols.ELT_ANNOTATIO ) {
// throw ValidationException(); }
//
} else {
facetData.put(facetElt.getLocalName(),facetElt.getAttribute( SchemaSymbols.ATT_VALUE ));
}
}
//content = (Element) content.getNextSibling();
content = XUtil.getNextSiblingElement(content);
}
if (numEnumerationLiterals > 0) {
facetData.put(SchemaSymbols.ELT_ENUMERATION, enumData);
}
}
// create & register validator for "generated" type if it doesn't exist
String nameOfType = fStringPool.toString( newSimpleTypeName);
if (fTargetNSURIString.length () != 0) {
nameOfType = fTargetNSURIString+","+nameOfType;
}
try {
DatatypeValidator newValidator =
fDatatypeRegistry.getDatatypeValidator( nameOfType );
if( newValidator == null ) { // not previously registered
boolean derivedByList =
varietyProperty.equals( SchemaSymbols.ATTVAL_LIST ) ? true:false;