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


Java Node.getFirstChild方法代码示例

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


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

示例1: getFirstElementChild

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
private Element getFirstElementChild(Node n) {
    final Node top = n;
    while (n != null) {
        if (n.getNodeType() == Node.ELEMENT_NODE) {
            return (Element) n;
        }
        Node next = n.getFirstChild();
        while (next == null) {         
            if (top == n) {
                break;
            }
            next = n.getNextSibling();
            if (next == null) {
                n = n.getParentNode();
                if (n == null || top == n) {
                    return null;
                }
            }
        }
        n = next;
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:24,代码来源:ElementImpl.java

示例2: setCellIndex

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void setCellIndex( int cellIndex )
{
    Node    parent;
    Node    child;
    
    parent = getParentNode();
    if ( parent instanceof HTMLTableRowElement )
    {
        child = parent.getFirstChild();
        while ( child != null )
        {
            if ( child instanceof HTMLTableCellElement )
            {
                if ( cellIndex == 0 )
                {
                    if ( this != child )
                        parent.insertBefore( this, child );
                    return;
                }
                -- cellIndex;
            }
            child = child.getNextSibling();
        }
    }
    parent.appendChild( this );
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:27,代码来源:HTMLTableCellElementImpl.java

示例3: hasTextOnlyChildren

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Check if an EntityReference node has Text Only child nodes
 * 
 * @param node
 * @return true - Contains text only children
 */
private boolean hasTextOnlyChildren(Node node) {

    Node child = node;
    
    if (child == null) {
        return false;
    }
    
    child = child.getFirstChild();
    while (child != null) {
        int type = child.getNodeType();
        
        if (type == Node.ENTITY_REFERENCE_NODE) {
            return hasTextOnlyChildren(child);
        } 
        else if (type != Node.TEXT_NODE
                && type != Node.CDATA_SECTION_NODE
                && type != Node.ENTITY_REFERENCE_NODE) {
            return false;
        }
        child = child.getNextSibling();
    }
    return true;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:31,代码来源:TextImpl.java

示例4: getCellIndex

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public int getCellIndex()
{
    Node    parent;
    Node    child;
    int        index;
    
    parent = getParentNode();
    index = 0;
    if ( parent instanceof HTMLTableRowElement )
    {
        child = parent.getFirstChild();
        while ( child != null )
        {
            if ( child instanceof HTMLTableCellElement )
            {
                if ( child == this )
                    return index;
                ++ index;
            }
            child = child.getNextSibling();
        }
    }
    return -1;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:25,代码来源:HTMLTableCellElementImpl.java

示例5: isEqualNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * DOM Level 3 WD- Experimental.
 * Override inherited behavior from NodeImpl to support deep equal.
 */
public boolean isEqualNode(Node arg) {
    if (!super.isEqualNode(arg)) {
        return false;
    }
    // there are many ways to do this test, and there isn't any way
    // better than another. Performance may vary greatly depending on
    // the implementations involved. This one should work fine for us.
    Node child1 = getFirstChild();
    Node child2 = arg.getFirstChild();
    while (child1 != null && child2 != null) {
        if (!child1.isEqualNode(child2)) {
            return false;
        }
        child1 = child1.getNextSibling();
        child2 = child2.getNextSibling();
    }
    if (child1 != child2) {
        return false;
    }
    return true;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:26,代码来源:ParentNode.java

示例6: 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

示例7: getFirstVisibleChildElement

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the first visible child element node. */
public static Element getFirstVisibleChildElement(Node parent) {
    
    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE &&
                !isHidden(child)) {
            return (Element)child;
        }
        child = child.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:18,代码来源:DOMUtil.java

示例8: getFirstChildElement

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Finds and returns the first child node with the given name and
 * attribute name, value pair.
 */
public static Element getFirstChildElement(Node   parent,
        String elemName,
        String attrName,
        String attrValue) {
    
    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            Element element = (Element)child;
            if (element.getNodeName().equals(elemName) &&
                    element.getAttribute(attrName).equals(attrValue)) {
                return element;
            }
        }
        child = child.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:27,代码来源:DOMUtil.java

示例9: getFirstChildElementNS

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** Finds and returns the first child node with the given qualified name. */
public static Element getFirstChildElementNS(Node parent,
        String uri, String localpart) {
    
    // search for node
    Node child = parent.getFirstChild();
    while (child != null) {
        if (child.getNodeType() == Node.ELEMENT_NODE) {
            String childURI = child.getNamespaceURI();
            if (childURI != null && childURI.equals(uri) &&
                    child.getLocalName().equals(localpart)) {
                return (Element)child;
            }
        }
        child = child.getNextSibling();
    }
    
    // not found
    return null;
    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:22,代码来源:DOMUtil.java

示例10: getElementById

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Recursive method retreives an element by its <code>id</code> attribute.
 * Called by {@link #getElementById(String)}.
 *
 * @param elementId The <code>id</code> value to look for
 * @return The node in which to look for
 */
private Element getElementById( String elementId, Node node )
{
    Node    child;
    Element    result;

    child = node.getFirstChild();
    while ( child != null )
    {
        if ( child instanceof Element )
        {
            if ( elementId.equals( ( (Element) child ).getAttribute( "id" ) ) )
                return (Element) child;
            result = getElementById( elementId, child );
            if ( result != null )
                return result;
        }
        child = child.getNextSibling();
    }
    return null;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:28,代码来源:HTMLDocumentImpl.java

示例11: nextNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
Node nextNode(Node node, boolean visitChildren) {
        
    if (node == null) return null;

    Node result;
    if (visitChildren) {
        result = node.getFirstChild();
        if (result != null) {
            return result;
        }
    }
        
    // if hasSibling, return sibling
    result = node.getNextSibling();
    if (result != null) {
        return result;
    }
    
            
    // return parent's 1st sibling.
    Node parent = node.getParentNode();
    while (parent != null
           && parent != fDocument
            ) {
        result = parent.getNextSibling();
        if (result != null) {
            return result;
        } else {
            parent = parent.getParentNode();
        }
                        
    } // while (parent != null && parent != fRoot) {
    
    // end of list, return null
    return null;            
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:37,代码来源:RangeImpl.java

示例12: indexOf

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/** what is the index of the child in the parent */
int indexOf(Node child, Node parent) {
    if (child.getParentNode() != parent) return -1;
    int i = 0;
    for(Node node = parent.getFirstChild(); node!= child; node=node.getNextSibling()) {
        i++;
    }
    return i;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:10,代码来源:RangeImpl.java

示例13: 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

示例14: getHead

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Obtains the &lt;HEAD&gt; element in the document, creating one if does
 * not exist before. The &lt;HEAD&gt; element is the first element in the
 * &lt;HTML&gt; in the document. The &lt;HTML&gt; element is obtained by
 * calling {@link #getDocumentElement}. If the element does not exist, one
 * is created.
 * <P>
 * Called by {@link #getTitle}, {@link #setTitle}, {@link #getBody} and
 * {@link #setBody} to assure the document has the &lt;HEAD&gt; element
 * correctly placed.
 *
 * @return The &lt;HEAD&gt; element
 */
public synchronized HTMLElement getHead()
{
    Node    head;
    Node    html;
    Node    child;
    Node    next;

    // Call getDocumentElement() to get the HTML element that is also the
    // top-level element in the document. Get the first element in the
    // document that is called HEAD. Work with that.
    html = getDocumentElement();
    synchronized ( html )
    {
        head = html.getFirstChild();
        while ( head != null && ! ( head instanceof HTMLHeadElement ) )
            head = head.getNextSibling();
        // HEAD exists but might not be first element in HTML: make sure
        // it is and return it.
        if ( head != null )
        {
            synchronized ( head )
            {
                child = html.getFirstChild();
                while ( child != null && child != head )
                {
                    next = child.getNextSibling();
                    head.insertBefore( child, head.getFirstChild() );
                    child = next;
                }
            }
            return (HTMLElement) head;
        }

        // Head does not exist, create a new one, place it at the top of the
        // HTML element and return it.
        head = new HTMLHeadElementImpl( this, "HEAD" );
        html.insertBefore( head, html.getFirstChild() );
    }
    return (HTMLElement) head;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:54,代码来源:HTMLDocumentImpl.java

示例15: checkUnboundNamespacePrefixedNode

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
/**
   * DOM Level 3:
   * Check a node to determine if it contains unbound namespace prefixes.
   *
   * @param node The node to check for unbound namespace prefices
   */
protected void checkUnboundNamespacePrefixedNode (Node node) throws IOException{

	if (fNamespaces) {

  			if (DEBUG) {
		    System.out.println("==>serializeNode("+node.getNodeName()+") [Entity Reference - Namespaces on]");
			System.out.println("==>Declared Prefix Count: " + fNSBinder.getDeclaredPrefixCount());
			System.out.println("==>Node Name: " + node.getNodeName());
			System.out.println("==>First Child Node Name: " + node.getFirstChild().getNodeName());
			System.out.println("==>First Child Node Prefix: " + node.getFirstChild().getPrefix());
			System.out.println("==>First Child Node NamespaceURI: " + node.getFirstChild().getNamespaceURI());			
		}

	
		Node child, next;
        for (child = node.getFirstChild(); child != null; child = next) {
            next = child.getNextSibling();
		    if (DEBUG) {
		        System.out.println("==>serializeNode("+child.getNodeName()+") [Child Node]");
		        System.out.println("==>serializeNode("+child.getPrefix()+") [Child Node Prefix]");
            }    

	 	    //If a NamespaceURI is not declared for the current
	 	    //node's prefix, raise a fatal error.
	 	    String prefix = child.getPrefix();
               prefix = (prefix == null || 
                       prefix.length() == 0) ? XMLSymbols.EMPTY_STRING : fSymbolTable.addSymbol(prefix);
	 	    if (fNSBinder.getURI(prefix) == null && prefix != null) {
				fatalError("The replacement text of the entity node '" 
							+ node.getNodeName()  
							+ "' contains an element node '" 
							+ child.getNodeName() 
							+ "' with an undeclared prefix '" 
							+ prefix + "'.");
	 	    }	

			if (child.getNodeType() == Node.ELEMENT_NODE) {
				
				NamedNodeMap attrs = child.getAttributes();
				
				for (int i = 0; i< attrs.getLength(); i++ ) {
					
			 	    String attrPrefix = attrs.item(i).getPrefix();
                       attrPrefix = (attrPrefix == null || 
                               attrPrefix.length() == 0) ? XMLSymbols.EMPTY_STRING : fSymbolTable.addSymbol(attrPrefix);
			 	    if (fNSBinder.getURI(attrPrefix) == null && attrPrefix != null) {
						fatalError("The replacement text of the entity node '" 
									+ node.getNodeName()  
									+ "' contains an element node '" 
									+ child.getNodeName() 
									+ "' with an attribute '" 
									+ attrs.item(i).getNodeName() 										
									+ "' an undeclared prefix '" 
									+ attrPrefix + "'.");
			 	    }	
					
				}	

			}
				
			if (child.hasChildNodes()) {
				checkUnboundNamespacePrefixedNode(child);
			}	
        }
	}    
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:73,代码来源:XMLSerializer.java


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