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

📄 schemautils.java

📁 Java有关XML编程需要用到axis 的源代码 把里面bin下的包导入相应的Java工程 进行使用
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                    } 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;    }    /**     * Invoked by getContainedElementDeclarations to get the child element types     * and child element names underneath a Choice Node     *     * @param choiceNode     * @param symbolTable     * @return     */    private static Vector processChoiceNode(Node choiceNode,                                            SymbolTable symbolTable) {        Vector v = new Vector();        NodeList children = choiceNode.getChildNodes();        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("choice")) {                    v.addAll(processChoiceNode(kid, symbolTable));                } else if (localName.equals("sequence")) {                    v.addAll(processSequenceNode(kid, symbolTable));                } else if (localName.equals("group")) {                    v.addAll(processGroupNode(kid, symbolTable));                } else if (localName.equals("element")) {                    ElementDecl elem = processChildElementNode(kid,                                                               symbolTable);                    if (elem != null) {                        // XXX: forces minOccurs="0" so that a null choice                        // element can be serialized ok.                        elem.setMinOccursIs0(true);                        v.add(elem);                    }                } else if (localName.equals("any")) {                    // Represent this as an element named any of type any type.                    // This will cause it to be serialized with the element                    // serializer.                    Type type = symbolTable.getType(Constants.XSD_ANY);                    ElementDecl elem = new ElementDecl(type,                            Utils.findQName("",                                    "any"));                    elem.setAnyElement(true);                    v.add(elem);                }            }        }        return v;    }    /**     * Returns named child node.     *     * @param parentNode Parent node.     * @param name Element name of child node to return.     */    private static Node getChildByName(Node parentNode, String name) throws DOMException {        if (parentNode == null) return null;        NodeList children = parentNode.getChildNodes();        if (children != null) {            for (int i = 0; i < children.getLength(); i++) {                Node child = children.item(i);                if (child != null) {                    if ((child.getNodeName() != null && (name.equals(child.getNodeName()))) ||                        (child.getLocalName() != null && (name.equals(child.getLocalName())))) {                        return child;                    }                }            }        }        return null;    }    /**     * Returns all textual nodes of a subnode defined by a parent node     * and a path of element names to that subnode.     *     * @param root Parent node.     * @param path Path of element names to text of interest, delimited by "/".     */    public static String getTextByPath(Node root, String path) throws DOMException {        StringTokenizer st = new StringTokenizer(path, "/");        Node node = root;        while (st.hasMoreTokens()) {            String elementName = st.nextToken();            Node child = getChildByName(node, elementName);            if (child == null)                throw new DOMException(DOMException.NOT_FOUND_ERR, "could not find " + elementName);            node = child;        }        // should have found the node        String text = "";        NodeList children = node.getChildNodes();        if (children != null) {            for (int i = 0; i < children.getLength(); i++) {                Node child = children.item(i);                if (child != null) {                    if (child.getNodeName() != null                            && (child.getNodeName().equals("#text")                            || child.getNodeName().equals("#cdata-section"))) {                        text += child.getNodeValue();                    }                }            }        }        return text;    }    /**     * Returns the complete text of the child xsd:annotation/xsd:documentation     * element from the provided node.  Only the first annotation element and     * the first documentation element in the annotation element will be used.     *     * @param typeNode Parent node.     */    public static String getAnnotationDocumentation(Node typeNode) {        Node annotationNode = typeNode.getFirstChild();        while (annotationNode != null) {            if (isXSDNode(annotationNode, "annotation")) {                break;            }            annotationNode = annotationNode.getNextSibling();        }        Node documentationNode;        if (annotationNode != null) {            documentationNode = annotationNode.getFirstChild();            while (documentationNode != null) {                if (isXSDNode(documentationNode, "documentation")) {                    break;                }                documentationNode = documentationNode.getNextSibling();            }        } else {            documentationNode = null;        }        // should have found the node if it exists        String text = "";        if (documentationNode != null) {            NodeList children = documentationNode.getChildNodes();            if (children != null) {                for (int i = 0; i < children.getLength(); i++) {                    Node child = children.item(i);                    if (child != null) {                        if (child.getNodeName() != null                                && (child.getNodeName().equals("#text")                                || child.getNodeName().equals("#cdata-section"))) {                            text += child.getNodeValue();                        }                    }                }            }        }        return text;    }    /**     * Invoked by getContainedElementDeclarations to get the child element types     * and child element names underneath a Sequence Node     *     * @param sequenceNode     * @param symbolTable     * @return     */    private static Vector processSequenceNode(Node sequenceNode,                                              SymbolTable symbolTable) {        Vector v = new Vector();        NodeList children = sequenceNode.getChildNodes();        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("choice")) {                    v.addAll(processChoiceNode(kid, symbolTable));                } else if (localName.equals("sequence")) {                    v.addAll(processSequenceNode(kid, symbolTable));                } else if (localName.equals("group")) {                    v.addAll(processGroupNode(kid, symbolTable));                } else if (localName.equals("any")) {                    // Represent this as an element named any of type any type.                    // This will cause it to be serialized with the element                    // serializer.                    Type type = symbolTable.getType(Constants.XSD_ANY);                    ElementDecl elem = new ElementDecl(type,                            Utils.findQName("",                                    "any"));                    elem.setAnyElement(true);                    v.add(elem);                } else if (localName.equals("element")) {                    ElementDecl elem = processChildElementNode(kid,                                                               symbolTable);                    if (elem != null) {                        v.add(elem);                    }                }            }        }        return v;    }    /**     * Invoked by getContainedElementDeclarations to get the child element types     * and child element names underneath a group node. If a ref attribute is     * specified, only the referenced group element is returned.     *     * @param groupNode     * @param symbolTable     * @return     */    private static Vector processGroupNode(Node groupNode,                                           SymbolTable symbolTable) {        Vector v = new Vector();        if (groupNode.getAttributes().getNamedItem("ref") == null) {            NodeList children = groupNode.getChildNodes();            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("choice")) {                        v.addAll(processChoiceNode(kid, symbolTable));                    } else if (localName.equals("sequence")) {                        v.addAll(processSequenceNode(kid, symbolTable));                    } else if (localName.equals("all")) {                        v.addAll(processAllNode(kid, symbolTable));                    }                }            }        } else {            QName nodeName = Utils.getNodeNameQName(groupNode);            QName nodeType = Utils.getTypeQName(groupNode, new BooleanHolder(), false);            // The value of the second argument is 'false' since global model group            // definitions are always represented by objects whose type is            // assignment compatible with 'org.apache.axis.wsdl.symbolTable.Type'.            Type type = (Type) symbolTable.getTypeEntry(nodeType, false);            if (type != null && type.getNode() != null) {                //v.add(new ElementDecl(type, nodeName));                Node node = type.getNode();                NodeList children = node.getChildNodes();                for (int j = 0; j < children.getLength(); j++) {                    QName subNodeKind = Utils.getNodeQName(children.item(j));                    if ((subNodeKind != null)                        && Constants.isSchemaXSD(                            subNodeKind.getNamespaceURI())) {                        if (subNodeKind.getLocalPart().equals("sequence")) {                            v.addAll(processSequenceNode(children.item(j),                                 symbolTable));                        } else if (subNodeKind.getLocalPart().equals("all")) {                            v.addAll(processAllNode(children.item(j), symbolTable));                            } else if (subNodeKind.getLocalPart().equals("choice")) {                                v.addAll(processChoiceNode(children.item(j),                                    symbolTable));                        }                    }                }            }        }        return v;    }    /**     * Invoked by getContainedElementDeclarations to get the child element types     * and child element names underneath an all node.     *     * @param allNode     * @param symbolTable     * @return     */    private static Vector processAllNode(Node allNode,                                         SymbolTable symbolTable) {        Vector v = new Vector();        NodeList children = allNode.getChildNodes();

⌨️ 快捷键说明

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