当前位置: 首页>>代码示例>>Java>>正文


Java SerializationHandler.namespaceAfterStartElement方法代码示例

本文整理汇总了Java中org.apache.xml.serializer.SerializationHandler.namespaceAfterStartElement方法的典型用法代码示例。如果您正苦于以下问题:Java SerializationHandler.namespaceAfterStartElement方法的具体用法?Java SerializationHandler.namespaceAfterStartElement怎么用?Java SerializationHandler.namespaceAfterStartElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.xml.serializer.SerializationHandler的用法示例。


在下文中一共展示了SerializationHandler.namespaceAfterStartElement方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: copyAttribute

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * Copy an Attribute node to a SerializationHandler
 *
 * @param nodeID The node identity
 * @param exptype The expanded type of the Element node
 * @param handler The SerializationHandler
 */
protected final void copyAttribute(int nodeID, int exptype,
    SerializationHandler handler)
    throws SAXException
{
    /*
        final String uri = getNamespaceName(node);
        if (uri.length() != 0) {
            final String prefix = getPrefix(node);
            handler.namespaceAfterStartElement(prefix, uri);
        }
        handler.addAttribute(getNodeName(node), getNodeValue(node));
    */
    final ExtendedType extType = m_extendedTypes[exptype];
    final String uri = extType.getNamespace();
    final String localName = extType.getLocalName();

    String prefix = null;
    String qname = null;
    int dataIndex = _dataOrQName(nodeID);
    int valueIndex = dataIndex;
        if (dataIndex <= 0) {
            int prefixIndex = m_data.elementAt(-dataIndex);
            valueIndex = m_data.elementAt(-dataIndex+1);
            qname = m_valuesOrPrefixes.indexToString(prefixIndex);
            int colonIndex = qname.indexOf(':');
            if (colonIndex > 0) {
                prefix = qname.substring(0, colonIndex);
            }
        }
        if (uri.length() != 0) {
            handler.namespaceAfterStartElement(prefix, uri);
        }

    String nodeName = (prefix != null) ? qname : localName;
    String nodeValue = (String)m_values.elementAt(valueIndex);

    handler.addAttribute(nodeName, nodeValue);
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:46,代码来源:SAX2DTM2.java

示例2: copyElement

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * Copy an Element node to a SerializationHandler.
 *
 * @param nodeID The node identity
 * @param exptype The expanded type of the Element node
 * @param handler The SerializationHandler
 * @return The qualified name of the Element node.
 */
protected final String copyElement(int nodeID, int exptype,
                           SerializationHandler handler)
    throws SAXException
{
    final ExtendedType extType = m_extendedTypes[exptype];
    String uri = extType.getNamespace();
    String name = extType.getLocalName();

    if (uri.length() == 0) {
        handler.startElement(name);
        return name;
    }
    else {
        int qnameIndex = m_dataOrQName.elementAt(nodeID);

        if (qnameIndex == 0) {
            handler.startElement(name);
            handler.namespaceAfterStartElement(EMPTY_STR, uri);
            return name;
        }

        if (qnameIndex < 0) {
	        qnameIndex = -qnameIndex;
	        qnameIndex = m_data.elementAt(qnameIndex);
        }

        String qName = m_valuesOrPrefixes.indexToString(qnameIndex);
        handler.startElement(qName);
        int prefixIndex = qName.indexOf(':');
        String prefix;
        if (prefixIndex > 0) {
            prefix = qName.substring(0, prefixIndex);
        }
        else {
            prefix = null;
        }
        handler.namespaceAfterStartElement(prefix, uri);
        return qName;
    }

}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:50,代码来源:SAX2DTM2.java

示例3: copyNS

import org.apache.xml.serializer.SerializationHandler; //导入方法依赖的package包/类
/**
 * Copy  namespace nodes.
 *
 * @param nodeID The Element node identity
 * @param handler The SerializationHandler
 * @param inScope  true if all namespaces in scope should be copied,
 *  false if only the namespace declarations should be copied.
 */
protected final void copyNS(final int nodeID, SerializationHandler handler, boolean inScope)
    throws SAXException
{
    // %OPT% Optimization for documents which does not have any explicit
    // namespace nodes. For these documents, there is an implicit
    // namespace node (xmlns:xml="http://www.w3.org/XML/1998/namespace")
    // declared on the root element node. In this case, there is no
    // need to do namespace copying. We can safely return without
    // doing anything.
    if (m_namespaceDeclSetElements != null &&
        m_namespaceDeclSetElements.size() == 1 &&
        m_namespaceDeclSets != null &&
        ((SuballocatedIntVector)m_namespaceDeclSets.elementAt(0))
        .size() == 1)
        return;

    SuballocatedIntVector nsContext = null;
    int nextNSNode;

    // Find the first namespace node
    if (inScope) {
        nsContext = findNamespaceContext(nodeID);
        if (nsContext == null || nsContext.size() < 1)
            return;
        else
            nextNSNode = makeNodeIdentity(nsContext.elementAt(0));
    }
    else
        nextNSNode = getNextNamespaceNode2(nodeID);

    int nsIndex = 1;
    while (nextNSNode != DTM.NULL) {
        // Retrieve the name of the namespace node
        int eType = _exptype2(nextNSNode);
        String nodeName = m_extendedTypes[eType].getLocalName();

        // Retrieve the node value of the namespace node
        int dataIndex = m_dataOrQName.elementAt(nextNSNode);

        if (dataIndex < 0) {
            dataIndex = -dataIndex;
            dataIndex = m_data.elementAt(dataIndex + 1);
        }

        String nodeValue = (String)m_values.elementAt(dataIndex);

        handler.namespaceAfterStartElement(nodeName, nodeValue);

        if (inScope) {
            if (nsIndex < nsContext.size()) {
                nextNSNode = makeNodeIdentity(nsContext.elementAt(nsIndex));
                nsIndex++;
            }
            else
                return;
        }
        else
            nextNSNode = getNextNamespaceNode2(nextNSNode);
    }
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:69,代码来源:SAX2DTM2.java


注:本文中的org.apache.xml.serializer.SerializationHandler.namespaceAfterStartElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。