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 complexNode = null;
for (int j = 0; j < children.getLength() && complexNode == null; j++) {
QName complexKind = Utils.getNodeQName(children.item(j));
if (complexKind != null &&
complexKind.getLocalPart().equals("complexType") &&
Constants.isSchemaXSD(complexKind.getNamespaceURI())) {
complexNode = children.item(j);
node = complexNode;
}
}
}
// Expecting a schema complexType
nodeKind = Utils.getNodeQName(node);
if (nodeKind != null &&
nodeKind.getLocalPart().equals("complexType") &&
Constants.isSchemaXSD(nodeKind.getNamespaceURI())) {
// Under the complexType there could be complexContent/simpleContent
// and extension elements if this is a derived type. Skip over these.
NodeList children = node.getChildNodes();
Node complexContent = null;
Node simpleContent = null;
Node extension = null;
for (int j = 0; j < children.getLength() && complexContent == null; j++) {
QName complexContentKind = Utils.getNodeQName(children.item(j));
if (complexContentKind != null &&
Constants.isSchemaXSD(complexContentKind.getNamespaceURI())) {
if (complexContentKind.getLocalPart().equals("complexContent") )
complexContent = children.item(j);
else if (complexContentKind.getLocalPart().equals("simpleContent"))
simpleContent = children.item(j);
}
}
if (complexContent != null) {
children = complexContent.getChildNodes();
for (int j = 0; j < children.getLength() && extension == null; j++) {
QName extensionKind = Utils.getNodeQName(children.item(j));
if (extensionKind != null &&
extensionKind.getLocalPart().equals("extension") &&
Constants.isSchemaXSD(extensionKind.getNamespaceURI()))
extension = children.item(j);
}
}
if (simpleContent != null) {
children = simpleContent.getChildNodes();
for (int j = 0; j < children.getLength() && extension == null; j++) {
QName extensionKind = Utils.getNodeQName(children.item(j));
if (extensionKind != null &&
extensionKind.getLocalPart().equals("extension") &&
Constants.isSchemaXSD(extensionKind.getNamespaceURI())) {
// get the type of the extension
QName extendsType =
Utils.getNodeTypeRefQName(children.item(j),
"base");
// Return an element declaration with a fixed name
// ("value") and the correct type.
Vector v = new Vector();
ElementDecl elem = new ElementDecl();
elem.setType(symbolTable.getTypeEntry(extendsType, false));
elem.setName(new javax.xml.rpc.namespace.QName("", "value"));
v.add(elem);
return v;
}
}
}
if (extension != null) {
node = extension; // Skip over complexContent and extension
}
// Under the complexType (or extension) there should be a sequence or all group node.
// (There may be other #text nodes, which we will ignore).
children = node.getChildNodes();
Node groupNode = null;
for (int j = 0; j < children.getLength() && groupNode == null; j++) {
QName groupKind = Utils.getNodeQName(children.item(j));
if (groupKind != null &&
(groupKind.getLocalPart().equals("sequence") ||
groupKind.getLocalPart().equals("all")) &&
Constants.isSchemaXSD(groupKind.getNamespaceURI()))
groupNode = children.item(j);
}
if (groupNode == null) {
// didn't find anything
return new Vector();
}
if (groupNode != null) {
// Process each of the choice or element nodes under the sequence/all node
Vector v = new Vector();
NodeList elements = groupNode.getChildNodes();
for (int i=0; i < elements.getLength(); i++) {
QName elementKind = Utils.getNodeQName(elements.item(i));
if (elementKind != null &&
Constants.isSchemaXSD(elementKind.getNamespaceURI())) {
if ( elementKind.getLocalPart().equals("element")) {
ElementDecl elem =
processChildElementNode(elements.item(i),
symbolTable);
if (elem != null)
v.add(elem);
} else if (elementKind.getLocalPart().equals("choice")) {
Vector choiceElems = processChoiceNode(elements.item(i), symbolTable);
v.addAll(choiceElems);
}
}
}