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


Java Node.getAttributes方法代码示例

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


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

示例1: dispatchingEventToSubtree

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Dispatches event to the target node's descendents recursively
 * 
 * @param n node to dispatch to
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchingEventToSubtree(Node n, Event e) {
	if (n==null) 
		return;
	
	// ***** Recursive implementation. This is excessively expensive,
    // and should be replaced in conjunction with optimization
    // mentioned above.
	((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);   
    dispatchingEventToSubtree(n.getNextSibling(), e);
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:23,代码来源:DocumentImpl.java

示例2: traverse

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public static void traverse(Node node, int depth) {
    indent(depth);
    System.out.print("<"+node.getNodeName());
    
    if (node.hasAttributes()) {
        NamedNodeMap attrs = node.getAttributes();
        for (int i=0; i<attrs.getLength(); i++) {
            System.out.print("  "+((Attr)attrs.item(i)).getName()+"=\""+((Attr)attrs.item(i)).getValue()+"\"");
        }
    }
    
    if (node.hasChildNodes()) {
        System.out.println(">");
        depth+=4;
        for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
            traverse(child, depth);
        }
        depth-=4;
        indent(depth);
        System.out.println("</"+node.getNodeName()+">");
    }
    else {
        System.out.println("/>");
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:26,代码来源:SchemaDOM.java

示例3: fillNamespaceContext

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private void fillNamespaceContext() {
    if (fRoot != null) {
        Node currentNode = fRoot.getParentNode();
        while (currentNode != null) {
            if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
                NamedNodeMap attributes = currentNode.getAttributes();
                final int attrCount = attributes.getLength();
                for (int i = 0; i < attrCount; ++i) {
                    Attr attr = (Attr) attributes.item(i);
                    String value = attr.getValue();
                    if (value == null) {
                        value = XMLSymbols.EMPTY_STRING;
                    }
                    fillQName(fAttributeQName, attr);
                    // REVISIT: Should we be looking at non-namespace attributes
                    // for additional mappings? Should we detect illegal namespace
                    // declarations and exclude them from the context? -- mrglavas
                    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
                        // process namespace attribute
                        if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                            declarePrefix0(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                        else {
                            declarePrefix0(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                    }
                }
                
            }
            currentNode = currentNode.getParentNode();
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:34,代码来源:DOMValidatorHelper.java

示例4: fillNamespaceContext

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
void fillNamespaceContext() {
    if (fSchemaRoot != null) {
        Node currentNode = fSchemaRoot.getParentNode();
        while (currentNode != null) {
            if (Node.ELEMENT_NODE == currentNode.getNodeType()) {
                NamedNodeMap attributes = currentNode.getAttributes();
                final int attrCount = attributes.getLength();
                for (int i = 0; i < attrCount; ++i) {
                    Attr attr = (Attr) attributes.item(i);
                    String value = attr.getValue();
                    if (value == null) {
                        value = XMLSymbols.EMPTY_STRING;
                    }
                    fillQName(fAttributeQName, attr);
                    // REVISIT: Should we be looking at non-namespace attributes
                    // for additional mappings? Should we detect illegal namespace
                    // declarations and exclude them from the context? -- mrglavas
                    if (fAttributeQName.uri == NamespaceContext.XMLNS_URI) {
                        // process namespace attribute
                        if (fAttributeQName.prefix == XMLSymbols.PREFIX_XMLNS) {
                            declarePrefix(fAttributeQName.localpart, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                        else {
                            declarePrefix(XMLSymbols.EMPTY_STRING, value.length() != 0 ? fSymbolTable.addSymbol(value) : null);
                        }
                    }
                }
                
            }
            currentNode = currentNode.getParentNode();
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:34,代码来源:SchemaNamespaceSupport.java

示例5: undeferChildren

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Traverses the DOM Tree and expands deferred nodes and their
 * children.
 * 
 */
protected void undeferChildren(Node node) {
    
    Node top = node;
    
    while (null != node) {
        
        if (((NodeImpl)node).needsSyncData()) {
            ((NodeImpl)node).synchronizeData();
        }
        
        NamedNodeMap attributes = node.getAttributes();
        if (attributes != null) {
            int length = attributes.getLength();
            for (int i = 0; i < length; ++i) {
                undeferChildren(attributes.item(i));
            }
        }
        
        Node nextNode = null;
        nextNode = node.getFirstChild();
        
        while (null == nextNode) {
            
            if (top.equals(node))
                break;
            
            nextNode = node.getNextSibling();
            
            if (null == nextNode) {
                node = node.getParentNode();
                
                if ((null == node) || (top.equals(node))) {
                    nextNode = null;
                    break;
                }
            }
        }
        
        node = nextNode;
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:47,代码来源:CoreDocumentImpl.java

示例6: dispatchEventToSubtree

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * NON-DOM INTERNAL: DOMNodeInsertedIntoDocument and ...RemovedFrom...
 * are dispatched to an entire subtree. This is the distribution code
 * therefor. They DO NOT bubble, thanks be, but may be captured.
 * <p>
 * Similar to code in dispatchingEventToSubtree however this method
 * is only used on the target node and does not start a dispatching chain
 * on the sibling of the target node as this is not part of the subtree 
 * ***** At the moment I'm being sloppy and using the normal
 * capture dispatcher on every node. This could be optimized hugely
 * by writing a capture engine that tracks our position in the tree to
 * update the capture chain without repeated chases up to root.
 * @param n target node (that was directly inserted or removed)
 * @param e event to be sent to that node and its subtree
 */
protected void dispatchEventToSubtree(Node n, Event e) {
    
    ((NodeImpl) n).dispatchEvent(e);
    if (n.getNodeType() == Node.ELEMENT_NODE) {
        NamedNodeMap a = n.getAttributes();
        for (int i = a.getLength() - 1; i >= 0; --i)
            dispatchingEventToSubtree(a.item(i), e);
    }
    dispatchingEventToSubtree(n.getFirstChild(), e);
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:27,代码来源:DocumentImpl.java


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