private void addTypes()

in axis-rt-core/src/main/java/org/apache/axis/wsdl/symbolTable/SymbolTable.java [985:1166]


    private void addTypes(URL context, Node node, int level)
            throws IOException, ParserConfigurationException, WSDLException,
            SAXException {

        if (node == null) {
            return;
        }

        // Get the kind of node (complexType, wsdl:part, etc.)
        String localPart = node.getLocalName();

        if (localPart != null) {
            boolean isXSD =
                    Constants.isSchemaXSD(node.getNamespaceURI());

            if (((isXSD && localPart.equals("complexType"))
                    || localPart.equals("simpleType"))) {

                // If an extension or restriction is present,
                // create a type for the reference
                Node re = SchemaUtils.getRestrictionOrExtensionNode(node);

                if ((re != null) && (Utils.getAttribute(re, "base") != null)) {
                    createTypeFromRef(re);
                }

                Node list = SchemaUtils.getListNode(node);
                if (list != null && Utils.getAttribute(list,"itemType") != null) {
                    createTypeFromRef(list);
                }

                Node union = SchemaUtils.getUnionNode(node);
                if (union != null) {
                    QName [] memberTypes = Utils.getMemberTypeQNames(union);
                    if (memberTypes != null) {
                        for (int i=0;i<memberTypes.length;i++) {
                            if (SchemaUtils.isSimpleSchemaType(memberTypes[i]) &&
                                getType(memberTypes[i]) == null) {
                                symbolTablePut(new BaseType(memberTypes[i]));
                            }
                        }
                    }
                }

                // This is a definition of a complex type.
                // Create a Type.
                createTypeFromDef(node, false, false);
            } else if (isXSD && localPart.equals("element")) {

                // Create a type entry for the referenced type
                createTypeFromRef(node);

                // If an extension or restriction is present,
                // create a type for the reference
                Node re = SchemaUtils.getRestrictionOrExtensionNode(node);

                if ((re != null) && (Utils.getAttribute(re, "base") != null)) {
                    createTypeFromRef(re);
                }

                // Create a type representing an element.  (This may
                // seem like overkill, but is necessary to support ref=
                // and element=.
                createTypeFromDef(node, true, level > SCHEMA_LEVEL);
            } else if (isXSD && localPart.equals("attributeGroup")) {

                // bug 23145: support attributeGroup (Brook Richan)
                // Create a type entry for the referenced type
                createTypeFromRef(node);

                // Create a type representing an attributeGroup.
                createTypeFromDef(node, false, level > SCHEMA_LEVEL);
            }  else if (isXSD && localPart.equals("group")) {
                // Create a type entry for the referenced type
                createTypeFromRef(node);
                // Create a type representing an group
                createTypeFromDef(node, false, level > SCHEMA_LEVEL);
            } else if (isXSD && localPart.equals("attribute")) {

                // Create a type entry for the referenced type
                BooleanHolder forElement = new BooleanHolder();
                QName refQName = Utils.getTypeQName(node, forElement,
                        false);

                if ((refQName != null) && !forElement.value) {
                    createTypeFromRef(node);

                    // Get the symbol table entry and make sure it is a simple
                    // type
                    if (refQName != null) {
                        TypeEntry refType = getTypeEntry(refQName, false);

                        if ((refType != null)
                                && (refType instanceof Undefined)) {

                            // Don't know what the type is.
                            // It better be simple so set it as simple
                            refType.setSimpleType(true);
                        } else if ((refType == null)
                                || (!(refType instanceof BaseType)
                                && !refType.isSimpleType())) {

                            // Problem if not simple
                            throw new IOException(
                                    Messages.getMessage(
                                            "AttrNotSimpleType01",
                                            refQName.toString()));
                        }
                    }
                }
                createTypeFromDef(node, true, level > SCHEMA_LEVEL);
            } else if (isXSD && localPart.equals("any")) {

                // Map xsd:any element to special xsd:any "type"
                if (getType(Constants.XSD_ANY) == null) {
                    Type type = new BaseType(Constants.XSD_ANY);

                    symbolTablePut(type);
                }
            } else if (localPart.equals("part")
                    && Constants.isWSDL(node.getNamespaceURI())) {

                // This is a wsdl part.  Create an TypeEntry representing the reference
                createTypeFromRef(node);
            } else if (isXSD && localPart.equals("include")) {
                String includeName = Utils.getAttribute(node, "schemaLocation");

                if (includeName != null) {
                    URL url = getURL(context, includeName);
                    Document includeDoc = newDocument(url.toString());

                    // Vidyanand : Fix for Bug #15124
                    org.w3c.dom.Element schemaEl =
                            includeDoc.getDocumentElement();

                    if (!schemaEl.hasAttribute("targetNamespace")) {
                        org.w3c.dom.Element parentSchemaEl =
                                (org.w3c.dom.Element) node.getParentNode();

                        if (parentSchemaEl.hasAttribute("targetNamespace")) {

                            // we need to set two things in here
                            // 1. targetNamespace
                            // 2. setup the xmlns=<targetNamespace> attribute
                            String tns =
                                    parentSchemaEl.getAttribute("targetNamespace");

                            schemaEl.setAttribute("targetNamespace", tns);
                            schemaEl.setAttribute("xmlns", tns);
                        }
                    }

                    populate(url, null, includeDoc, url.toString());
                }
            }
        }

        if (level == ABOVE_SCHEMA_LEVEL) {
            if ((localPart != null)
                && localPart.equals("schema")) {
                level = SCHEMA_LEVEL;
                String targetNamespace = ((org.w3c.dom.Element) node).getAttribute("targetNamespace");
                String elementFormDefault = ((org.w3c.dom.Element) node).getAttribute("elementFormDefault");
                if (targetNamespace != null && targetNamespace.length() > 0) {
                    elementFormDefault = (elementFormDefault == null || elementFormDefault.length() == 0) ?
                            "unqualified" : elementFormDefault;
                    if(elementFormDefaults.get(targetNamespace)==null) {
                        elementFormDefaults.put(targetNamespace, elementFormDefault);
                    }
                }
            }
        } else {
            ++level;
        }

        // Recurse through children nodes
        NodeList children = node.getChildNodes();

        for (int i = 0; i < children.getLength(); i++) {
            addTypes(context, children.item(i), level);
        }
    }    // addTypes