if (node == null) {
return null;
}
// If the node kind is an element, dive into it.
QName nodeKind = Utils.getNodeQName(node);
if (nodeKind != null &&
nodeKind.getLocalPart().equals("element") &&
Constants.isSchemaXSD(nodeKind.getNamespaceURI())) {
NodeList children = node.getChildNodes();
Node simpleNode = null;
for (int j = 0; j < children.getLength() && simpleNode == null; j++) {
QName simpleKind = Utils.getNodeQName(children.item(j));
if (simpleKind != null &&
simpleKind.getLocalPart().equals("simpleType") &&
Constants.isSchemaXSD(simpleKind.getNamespaceURI())) {
simpleNode = children.item(j);
node = simpleNode;
}
}
}
// Get the node kind, expecting a schema simpleType
nodeKind = Utils.getNodeQName(node);
if (nodeKind != null &&
nodeKind.getLocalPart().equals("simpleType") &&
Constants.isSchemaXSD(nodeKind.getNamespaceURI())) {
// Under the simpleType there should be a restriction.
// (There may be other #text nodes, which we will ignore).
NodeList children = node.getChildNodes();
Node restrictionNode = null;
for (int j = 0; j < children.getLength() && restrictionNode == null; j++) {
QName restrictionKind = Utils.getNodeQName(children.item(j));
if (restrictionKind != null &&
restrictionKind.getLocalPart().equals("restriction") &&
Constants.isSchemaXSD(restrictionKind.getNamespaceURI()))
restrictionNode = children.item(j);
}
// The restriction node indicates the type being restricted
// (the base attribute contains this type).
// The base type must be a built-in type, and not boolean
TypeEntry baseEType = null;
if (restrictionNode != null) {
QName baseType = Utils.getNodeTypeRefQName(restrictionNode, "base");
baseEType = symbolTable.getType(baseType);
if (baseEType != null) {
String javaName = baseEType.getName();
if (javaName.equals("java.lang.String") ||
javaName.equals("int") ||
javaName.equals("long") ||
javaName.equals("short") ||
javaName.equals("float") ||
javaName.equals("double") ||
javaName.equals("byte"))
; // Okay Type
else
baseEType = null;
}
}
// Process the enumeration elements underneath the restriction node
if (baseEType != null && restrictionNode != null) {
Vector v = new Vector();
NodeList enums = restrictionNode.getChildNodes();
for (int i=0; i < enums.getLength(); i++) {
QName enumKind = Utils.getNodeQName(enums.item(i));
if (enumKind != null &&
enumKind.getLocalPart().equals("enumeration") &&
Constants.isSchemaXSD(enumKind.getNamespaceURI())) {
// Put the enum value in the vector.
Node enumNode = enums.item(i);
String value = Utils.getAttribute(enumNode, "value");
if (value != null) {