⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 symboltable.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                            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    /**     * Create a TypeEntry from the indicated node, which defines a type     * that represents a complexType, simpleType or element (for ref=).     *      * @param node                  * @param isElement             * @param belowSchemaLevel      * @throws IOException      */    private void createTypeFromDef(            Node node, boolean isElement, boolean belowSchemaLevel)            throws IOException {        // Get the QName of the node's name attribute value        QName qName = Utils.getNodeNameQName(node);        if (qName != null) {            // If the qname is already registered as a base type,            // don't create a defining type/element.            if (!isElement && (btm.getBaseName(qName) != null)) {                return;            }            // If the node has a type or ref attribute, get the            // qname representing the type            BooleanHolder forElement = new BooleanHolder();            QName refQName = Utils.getTypeQName(node, forElement,                    false);            if (refQName != null) {                // Error check - bug 12362                if (qName.getLocalPart().length() == 0) {                    String name = Utils.getAttribute(node, "name");                    if (name == null) {                        name = "unknown";                    }                    throw new IOException(Messages.getMessage("emptyref00",                            name));                }                // Now get the TypeEntry                TypeEntry refType = getTypeEntry(refQName, forElement.value);                if (!belowSchemaLevel) {                    if (refType == null) {                        throw new IOException(                                Messages.getMessage(                                        "absentRef00", refQName.toString(),                                        qName.toString()));                    }                    symbolTablePut(new DefinedElement(qName, refType, node,                            ""));                }            } else {                // Flow to here indicates no type= or ref= attribute.                // See if this is an array or simple type definition.                IntHolder numDims = new IntHolder();                BooleanHolder underlTypeNillable = new BooleanHolder();                // If we're supposed to unwrap arrays, supply someplace to put the "inner" QName                // so we can propagate it into the appropriate metadata container.                QNameHolder itemQName = wrapArrays ? null : new QNameHolder();                BooleanHolder forElement2 = new BooleanHolder();                numDims.value = 0;                QName arrayEQName =                         SchemaUtils.getArrayComponentQName(node,                                                           numDims,                                                           underlTypeNillable,                                                           itemQName,                                                           forElement2,                                                           this);                if (arrayEQName != null) {                    // Get the TypeEntry for the array element type                    refQName = arrayEQName;                    TypeEntry refType = getTypeEntry(refQName, forElement2.value);                    if (refType == null) {//                        arrayTypeQNames.add(refQName);                        // Not defined yet, add one                        String baseName = btm.getBaseName(refQName);                        if (baseName != null) {                            refType = new BaseType(refQName);                        } else if(forElement2.value) {                            refType = new UndefinedElement(refQName);                        } else {                            refType = new UndefinedType(refQName);                        }                        symbolTablePut(refType);                    }                    // Create a defined type or element that references refType                    String dims = "";                    while (numDims.value > 0) {                        dims += "[]";                        numDims.value--;                    }                    TypeEntry defType = null;                    if (isElement) {                        if (!belowSchemaLevel) {                            defType =                               new DefinedElement(qName, refType, node, dims);                            // Save component type for ArraySerializer                            defType.setComponentType(arrayEQName);                            if (itemQName != null)                                defType.setItemQName(itemQName.value);                        }                    } else {                        defType = new DefinedType(qName, refType, node, dims);                        // Save component type for ArraySerializer                        defType.setComponentType(arrayEQName);                        defType.setUnderlTypeNillable(underlTypeNillable.value);                        if (itemQName != null)                            defType.setItemQName(itemQName.value);                    }                    if (defType != null) {                        symbolTablePut(defType);                    }                } else {                    // Create a TypeEntry representing this  type/element                    String baseName = btm.getBaseName(qName);                    if (baseName != null) {                        symbolTablePut(new BaseType(qName));                    } else {                        // Create a type entry, set whether it should                        // be mapped as a simple type, and put it in the                        // symbol table.                        TypeEntry te = null;                        TypeEntry parentType = null;                        if (!isElement) {                            te = new DefinedType(qName, node);                            // check if we are an anonymous type underneath                            // an element.  If so, we point the refType of the                            // element to us (the real type).                            if (qName.getLocalPart().indexOf(ANON_TOKEN) >= 0) {                                Node parent = node.getParentNode();                                QName parentQName =                                        Utils.getNodeNameQName(parent);                                parentType = getElement(parentQName);                            }                        } else {                            if (!belowSchemaLevel) {                                te = new DefinedElement(qName, node);                            }                        }                        if (te != null) {                            if (SchemaUtils.isSimpleTypeOrSimpleContent(node)) {                                te.setSimpleType(true);                            }                            te = (TypeEntry)symbolTablePut(te);                            if (parentType != null) {                                parentType.setRefType(te);                            }                        }                    }                }            }        }    }    // createTypeFromDef    /**     * Node may contain a reference (via type=, ref=, or element= attributes) to     * another type.  Create a Type object representing this referenced type.     *     * @param node     * @throws IOException     */    protected void createTypeFromRef(Node node) throws IOException {        // Get the QName of the node's type attribute value        BooleanHolder forElement = new BooleanHolder();        QName qName = Utils.getTypeQName(node, forElement, false);        if (qName == null || (Constants.isSchemaXSD(qName.getNamespaceURI()) &&                qName.getLocalPart().equals("simpleRestrictionModel"))) {            return;        }        // Error check - bug 12362        if (qName.getLocalPart().length() == 0) {            String name = Utils.getAttribute(node, "name");            if (name == null) {                name = "unknown";            }            throw new IOException(Messages.getMessage("emptyref00", name));        }        // Get Type or Element depending on whether type attr was used.        TypeEntry type = getTypeEntry(qName, forElement.value);        // A symbol table entry is created if the TypeEntry is not found        if (type == null) {            // See if this is a special QName for collections            if (qName.getLocalPart().indexOf("[") > 0) {                QName containedQName = Utils.getTypeQName(node,                        forElement, true);                TypeEntry containedTE = getTypeEntry(containedQName,                        forElement.value);                if (!forElement.value) {                    // Case of type and maxOccurs                    if (containedTE == null) {                        // Collection Element Type not defined yet, add one.                        String baseName = btm.getBaseName(containedQName);                        if (baseName != null) {                            containedTE = new BaseType(containedQName);                        } else {                            containedTE = new UndefinedType(containedQName);                        }                        symbolTablePut(containedTE);                    }                    boolean wrapped = qName.getLocalPart().endsWith("wrapped");                    symbolTablePut(new CollectionType(qName, containedTE,                            node, "[]", wrapped));                } else {                    // Case of ref and maxOccurs                    if (containedTE == null) {                        containedTE = new UndefinedElement(containedQName);                        symbolTablePut(containedTE);                    }                    symbolTablePut(new CollectionElement(qName,                            containedTE, node,                            "[]"));                }            } else {                // Add a BaseType or Undefined Type/Element                String baseName = btm.getBaseName(qName);                if (baseName != null) {                    symbolTablePut(new BaseType(qName));                    // bugzilla 23145: handle attribute groups                    // soap/encoding is treated as a "known" schema                    // so now let's act like we know it                } else if (qName.equals(Constants.SOAP_COMMON_ATTRS11)) {                    symbolTablePut(new BaseType(qName));                    // the 1.1 commonAttributes type contains two attributes                    // make sure those attributes' types are in the symbol table                    // attribute name = "id" type = "xsd:ID"                    if (getTypeEntry(Constants.XSD_ID, false) == null) {                        symbolTablePut(new BaseType(Constants.XSD_ID));                    }                    // attribute name = "href" type = "xsd:anyURI"                    if (getTypeEntry(Constants.XSD_ANYURI, false) == null) {                        symbolTablePut(new BaseType(Constants.XSD_ANYURI));                    }                } else if (qName.equals(Constants.SOAP_COMMON_ATTRS12)) {                    symbolTablePut(new BaseType(qName));                    // the 1.2 commonAttributes type contains one attribute                    // make sure the attribute's type is in the symbol table                    // attribute name = "id" type = "xsd:ID"                    if (getTypeEntry(Constants.XSD_ID, false) == null) {                        symbolTablePut(new BaseType(Constants.XSD_ID));                    }                } else if (qName.equals(Constants.SOAP_ARRAY_ATTRS11)) {                    symbolTablePut(new BaseType(qName));                    // the 1.1 arrayAttributes type contains two attributes                    // make sure the attributes' types are in the symbol table                    // attribute name = "arrayType" type = "xsd:string"                    if (getTypeEntry(Constants.XSD_STRING, false) == null) {                        symbolTablePut(new BaseType(Constants.XSD_STRING));                    }                    // attribute name = "offset" type = "soapenc:arrayCoordinate"                    // which is really an xsd:string                } else if (qName.equals(Constants.SOAP_ARRAY_ATTRS12)) {                    symbolTablePut(new BaseType(qName));                    // the 1.2 arrayAttributes type contains two attributes                    // make sure the attributes' types are in the symbol table                    // attribute name = "arraySize" type = "2003soapenc:arraySize"                    // which is really a hairy beast that is not                    // supported, yet; so let's just use string                    if (getTypeEntry(Constants.XSD_STRING, false) == null) {                        symbolTablePut(new BaseType(Constants.XSD_STRING));                    }                    // attribute name = "itemType" type = "xsd:QName"                    if (getTypeEntry(Constants.XSD_QNAME, false) == null) {                        symbolTablePut(new BaseType(Constants.XSD_QNAME));                    }                } else if (forElement.value == false) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -