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

📄 dommapperbase.java

📁 对xml很好的java处理引擎,编译中绑定xml
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                        defuri = decluri;                    }                    if (uri == decluri) {                        nsi = defind;                    }                }            }        }                // check for namespace declarations required        String[] uris = null;        if (nss == null) {            m_xmlWriter.startTagOpen(nsi, element.getLocalName());        } else {            int base = getNextNamespaceIndex();            if (defind >= 0) {                m_defaultNamespaceIndex = base + defind;                m_defaultNamespaceURI = defuri;            }            int length = nss.size() / 2;            uris = new String[length];            int[] nums = new int[length];            String[] prefs = new String[length];            for (int i = 0; i < length; i++) {                prefs[i] = (String)nss.get(i*2);                uris[i] = (String)nss.get(i*2+1);                nums[i] = base + i;                if (nsi < 0 && uri.equals(uris[i])) {                    if ((prefix == null && prefs[i] == "") ||                        (prefix != null && prefix.equals(prefs[i]))) {                        nsi = base + i;                    }                }            }            m_xmlWriter.pushExtensionNamespaces(uris);            m_xmlWriter.startTagNamespaces(nsi, element.getLocalName(),                nums, prefs);            if (defind >= 0) {                m_defaultNamespaceIndex = defind;                m_defaultNamespaceURI = defuri;            }        }                // add attributes if present        for (int i = 0; i < size; i++) {            Attr attr = (Attr)attrs.item(i);            if (!XMLNS_NAMESPACE.equals(attr.getNamespaceURI())) {                int index = 0;                String apref = attr.getPrefix();                if (apref != null) {                    index = findNamespaceIndex(apref, attr.getNamespaceURI());                }                m_xmlWriter.addAttribute(index, attr.getLocalName(),                     attr.getValue());            }        }                // check for content present        NodeList nodes = element.getChildNodes();        size = nodes.getLength();        if (size > 0) {            m_xmlWriter.closeStartTag();            marshalContent(element.getChildNodes());            m_xmlWriter.endTag(nsi, element.getLocalName());        } else {            m_xmlWriter.closeEmptyTag();        }                // pop namespaces if defined by element        if (nss != null) {            m_xmlWriter.popExtensionNamespaces();            if (defind >= 0) {                m_defaultNamespaceURI = null;            }        }    }        /**     * Unmarshal single node. This unmarshals the next node from the input     * stream, up to the close tag of the containing element.     *     * @return unmarshalled node     * @exception JiBXException on error in unmarshalling     * @exception IOException on error reading input     */        protected Node unmarshalNode() throws JiBXException, IOException {        while (true) {            int cev = m_unmarshalContext.currentEvent();            switch (cev) {                                case IXMLReader.CDSECT:                    {                        String text = m_unmarshalContext.getText();                        m_unmarshalContext.nextToken();                        return m_document.createCDATASection(text);                    }                                case IXMLReader.COMMENT:                    {                        String text = m_unmarshalContext.getText();                        m_unmarshalContext.nextToken();                        return m_document.createComment(text);                    }                                case IXMLReader.END_TAG:                    return null;                                case IXMLReader.ENTITY_REF:                    if (m_unmarshalContext.getText() == null) {                        String name = m_unmarshalContext.getName();                        m_unmarshalContext.nextToken();                        return m_document.createEntityReference(name);                    } else {                        String text = accumulateText();                        return m_document.createTextNode(text);                    }                                case IXMLReader.PROCESSING_INSTRUCTION:                    {                        String text = m_unmarshalContext.getText();                        m_unmarshalContext.nextToken();                        int index = 0;                        while (++index < text.length() &&                            !isWhitespace(text.charAt(index)));                        if (index < text.length()) {                            String target = text.substring(0, index);                            while (++index < text.length() &&                                isWhitespace(text.charAt(index)));                            String data = text.substring(index);                            return m_document.                                createProcessingInstruction(target, data);                        } else {                            return m_document.                                createProcessingInstruction(text, "");                        }                    }                                case IXMLReader.START_TAG:                    return unmarshalElement();                                case IXMLReader.TEXT:                    return m_document.createTextNode(accumulateText());                                    default:                    m_unmarshalContext.nextToken();                                }        }    }        /**     * Unmarshal node content. This unmarshals everything up to the containing     * element close tag, adding each component to the content list supplied. On     * return, the parse position will always be at an END_TAG.     *     * @param parent node to which children are to be added      * @exception JiBXException on error in unmarshalling     * @exception IOException on error reading input     */        protected void unmarshalContent(Node parent)        throws JiBXException, IOException {        Node node;        while ((node = unmarshalNode()) != null) {            parent.appendChild(node);        }    }        /**     * Unmarshal element with all attributes and content. This must be called     * with the unmarshalling context positioned at a START_TAG event.     *     * @return unmarshalled element     * @exception JiBXException on error in unmarshalling     * @exception IOException on error reading input     */        protected Element unmarshalElement() throws JiBXException, IOException {                // start by creating the actual element        String uri = m_unmarshalContext.getNamespace();        String prefix = m_unmarshalContext.getPrefix();        String name = m_unmarshalContext.getName();        if (prefix != null) {            name = prefix + ':' + name;        }        Element element = m_document.createElementNS(uri, name);                // add all namespace declarations to element        int ncount = m_unmarshalContext.getNamespaceCount();        for (int i = 0; i < ncount; i++) {            prefix = m_unmarshalContext.getNamespacePrefix(i);            uri = m_unmarshalContext.getNamespaceUri(i);            if (prefix == null) {                element.setAttributeNS(XMLNS_NAMESPACE, "xmlns", uri);            } else {                element.setAttributeNS(XMLNS_NAMESPACE, "xmlns:" + prefix, uri);            }        }                // add all attributes to element        int acount = m_unmarshalContext.getAttributeCount();        for (int i = 0; i < acount; i++) {            prefix = m_unmarshalContext.getAttributePrefix(i);            uri = m_unmarshalContext.getAttributeNamespace(i);            name = m_unmarshalContext.getAttributeName(i);            if (prefix != null) {                name = prefix + ':' + name;            }            String value = m_unmarshalContext.getAttributeValue(i);            element.setAttributeNS(uri, name, value);        }                // add all content to element        int event = m_unmarshalContext.nextToken();        if (event != IXMLReader.END_TAG) {            unmarshalContent(element);        }        m_unmarshalContext.nextToken();        return element;    }}

⌨️ 快捷键说明

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