in axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SchemaUtils.java [230:428]
public static Vector getContainedElementDeclarations(Node node,
SymbolTable symbolTable) {
if (node == null) {
return null;
}
// If the node kind is an element, dive into it.
if (isXSDNode(node, "element")) {
NodeList children = node.getChildNodes();
for (int j = 0; j < children.getLength(); j++) {
Node kid = children.item(j);
if (isXSDNode(kid, "complexType")) {
node = kid;
break;
}
}
}
// Expecting a schema complexType or simpleType
if (isXSDNode(node, "complexType")) {
// 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(); j++) {
Node kid = children.item(j);
if (isXSDNode(kid, "complexContent")) {
complexContent = kid;
break; // REMIND: should this be here or on either branch?
} else if (isXSDNode(kid, "simpleContent")) {
simpleContent = kid;
}
}
if (complexContent != null) {
children = complexContent.getChildNodes();
for (int j = 0;
(j < children.getLength()) && (extension == null);
j++) {
Node kid = children.item(j);
if (isXSDNode(kid, "extension")
|| isXSDNode(kid, "restriction")) {
extension = kid;
}
}
}
if (simpleContent != null) {
children = simpleContent.getChildNodes();
int len = children.getLength();
for (int j = 0;
(j < len) && (extension == null);
j++) {
Node kid = children.item(j);
String localName = kid.getLocalName();
if ((localName != null)
&& (localName.equals("extension") || localName.equals("restriction"))
&& Constants.isSchemaXSD(kid.getNamespaceURI())) {
// get the type of the extension/restriction from the "base" attribute
QName extendsOrRestrictsTypeName =
Utils.getTypeQName(children.item(j),
new BooleanHolder(), false);
TypeEntry extendsOrRestrictsType =
symbolTable.getTypeEntry(extendsOrRestrictsTypeName,
false);
// If this type extends a simple type, then add the
// special "value" ElementDecl, else this type is
// extending another simpleContent type and will
// already have a "value".
if (extendsOrRestrictsType == null ||
extendsOrRestrictsType.isBaseType())
{
// Return an element declaration with a fixed name
// ("value") and the correct type.
Vector v = new Vector();
ElementDecl elem =
new ElementDecl(extendsOrRestrictsType,
VALUE_QNAME);
v.add(elem);
return v;
}
else
{
// There can't be any other elements in a
// simpleContent node.
return null;
}
}
}
}
if (extension != null) {
node = extension; // Skip over complexContent and extension
}
// Under the complexType there may be choice, sequence, group and/or all nodes.
// (There may be other #text nodes, which we will ignore).
children = node.getChildNodes();
Vector v = new Vector();
int len = children.getLength();
for (int j = 0; j < len; j++) {
Node kid = children.item(j);
String localName = kid.getLocalName();
if (localName != null &&
Constants.isSchemaXSD(kid.getNamespaceURI())) {
if (localName.equals("sequence")) {
v.addAll(processSequenceNode(kid, symbolTable));
} else if (localName.equals("all")) {
v.addAll(processAllNode(kid, symbolTable));
} else if (localName.equals("choice")) {
v.addAll(processChoiceNode(kid, symbolTable));
} else if (localName.equals("group")) {
v.addAll(processGroupNode(kid, symbolTable));
}
}
}
return v;
} else if (isXSDNode(node, "group")) {
/*
* Does this else clause make any sense anymore if
* we're treating refs to xs:groups like a macro inclusion
* into the referencing type?
* Maybe this else clause should never be possible?
*
NodeList children = node.getChildNodes();
Vector v = new Vector();
int len = children.getLength();
for (int j = 0; j < len; j++) {
Node kid = children.item(j);
String localName = kid.getLocalName();
if (localName != null &&
Constants.isSchemaXSD(kid.getNamespaceURI())) {
if (localName.equals("sequence")) {
v.addAll(processSequenceNode(kid, symbolTable));
} else if (localName.equals("all")) {
v.addAll(processAllNode(kid, symbolTable));
} else if (localName.equals("choice")) {
v.addAll(processChoiceNode(kid, symbolTable));
}
}
}
return v;
*/
return null;
} else {
// This may be a simpleType, return the type with the name "value"
QName[] simpleQName = getContainedSimpleTypes(node);
if (simpleQName != null) {
Vector v = null;
for (int i = 0; i < simpleQName.length; i++) {
Type simpleType = symbolTable.getType(simpleQName[i]);
if (simpleType != null) {
if (v == null) {
v = new Vector();
}
QName qname = null;
if (simpleQName.length > 1) {
qname = new QName("", simpleQName[i].getLocalPart() + "Value");
} else {
qname = new QName("", "value");
}
v.add(new ElementDecl(simpleType, qname));
}
}
return v;
}
}
return null;
}