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


Java Node.appendChild方法代码示例

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


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

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

示例2: insertRowX

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
void insertRowX( int index, HTMLTableRowElementImpl newRow )
{
    Node    child;
    Node    lastSection = null;
            
    child = getFirstChild();
    while ( child != null )
    {
        if ( child instanceof HTMLTableRowElement )
        {
            if ( index == 0 )
            {
                insertBefore( newRow, child );
                return;
            }
        }
        else
        if ( child instanceof HTMLTableSectionElementImpl )
        {
            lastSection = child;
            index = ( (HTMLTableSectionElementImpl) child ).insertRowX( index, newRow );
            if ( index < 0 )
                return;
        }
        child = child.getNextSibling();
    }
    if ( lastSection != null )
        lastSection.appendChild( newRow );
    else
        appendChild( newRow );
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:32,代码来源:HTMLTableElementImpl.java

示例3: surroundContents

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public void surroundContents(Node newParent)
    throws DOMException, RangeException
{
    if (newParent==null) return;
    int type = newParent.getNodeType();
    
    if (fDocument.errorChecking) {
        if (fDetach) {
            throw new DOMException(
                    DOMException.INVALID_STATE_ERR, 
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_STATE_ERR", null));
        }
        if (type == Node.ATTRIBUTE_NODE
                || type == Node.ENTITY_NODE
                || type == Node.NOTATION_NODE
                || type == Node.DOCUMENT_TYPE_NODE
                || type == Node.DOCUMENT_NODE
                || type == Node.DOCUMENT_FRAGMENT_NODE)
        {
            throw new RangeExceptionImpl(
                    RangeException.INVALID_NODE_TYPE_ERR, 
                    DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "INVALID_NODE_TYPE_ERR", null));
        }
    }
    
    Node realStart = fStartContainer;
    Node realEnd = fEndContainer;
    if (fStartContainer.getNodeType() == Node.TEXT_NODE) {
        realStart = fStartContainer.getParentNode();
    }
    if (fEndContainer.getNodeType() == Node.TEXT_NODE) {
        realEnd = fEndContainer.getParentNode();
    }
        
    if (realStart != realEnd) {
       	throw new RangeExceptionImpl(
		RangeException.BAD_BOUNDARYPOINTS_ERR, 
            DOMMessageFormatter.formatMessage(DOMMessageFormatter.DOM_DOMAIN, "BAD_BOUNDARYPOINTS_ERR", null));
    }

	DocumentFragment frag = extractContents();
	insertNode(newParent);
	newParent.appendChild(frag);
	selectNode(newParent);
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:46,代码来源:RangeImpl.java

示例4: getDocumentElement

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized Element getDocumentElement()
{
    Node    html;
    Node    child;
    Node    next;

    // The document element is the top-level HTML element of the HTML
    // document. Only this element should exist at the top level.
    // If the HTML element is found, all other elements that might
    // precede it are placed inside the HTML element.
    html = getFirstChild();
    while ( html != null )
    {
        if ( html instanceof HTMLHtmlElement )
        {
            // REVISIT: [Q] Why is this code even here? In fact, the
            //          original code is in error because it will
            //          try to move ALL nodes to be children of the
            //          HTML tag. This is not the intended behavior
            //          for comments and processing instructions
            //          outside the root element; it will throw a
            //          hierarchy request error exception for doctype
            //          nodes; *and* this code shouldn't even be
            //          needed because the parser should never build
            //          a document that contains more than a single
            //          root element, anyway! -Ac
            /***
            synchronized ( html )
            {
                child = getFirstChild();
                while ( child != null && child != html )
                {
                    next = child.getNextSibling();
                    html.appendChild( child );
                    child = next;
                }
            }
            /***/
            return (HTMLElement) html;
        }
        html = html.getNextSibling();
    }

    // HTML element must exist. Create a new element and dump the
    // entire contents of the document into it in the same order as
    // they appear now.
    html = new HTMLHtmlElementImpl( this, "HTML" );
    child = getFirstChild();
    while ( child != null )
    {
        next = child.getNextSibling();
        html.appendChild( child );
        child = next;
    }
    appendChild( html );
    return (HTMLElement) html;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:58,代码来源:HTMLDocumentImpl.java

示例5: getBody

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized HTMLElement getBody()
{
    Node    html;
    Node    head;
    Node    body;
    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 BODY. Work with that.
    html = getDocumentElement();
    head = getHead();
    synchronized ( html )
    {
        body = head.getNextSibling();
        while ( body != null && ! ( body instanceof HTMLBodyElement )
                && ! ( body instanceof HTMLFrameSetElement ) )
            body = body.getNextSibling();

        // BODY/FRAMESET exists but might not be second element in HTML
        // (after HEAD): make sure it is and return it.
        if ( body != null )
        {
            synchronized ( body )
            {
                child = head.getNextSibling();
                while ( child != null && child != body )
                {
                    next = child.getNextSibling();
                    body.insertBefore( child, body.getFirstChild() );
                    child = next;
                }
            }
            return (HTMLElement) body;
        }

        // BODY does not exist, create a new one, place it in the HTML element
        // right after the HEAD and return it.
        body = new HTMLBodyElementImpl( this, "BODY" );
        html.appendChild( body );
    }
    return (HTMLElement) body;
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:45,代码来源:HTMLDocumentImpl.java

示例6: setBody

import mf.org.w3c.dom.Node; //导入方法依赖的package包/类
public synchronized void setBody( HTMLElement newBody )
{
    Node    html;
    Node    body;
    Node    head;
    Node    child;
    NodeList list;

    synchronized ( newBody )
    {
        // 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 BODY. Work with that.
        html = getDocumentElement();
        head = getHead();
        synchronized ( html )
        {
            list = this.getElementsByTagName( "BODY" );
            if ( list.getLength() > 0 ) {
                // BODY exists but might not follow HEAD in HTML. If not,
                // make it so and replce it. Start with the HEAD and make
                // sure the BODY is the first element after the HEAD.
                body = list.item( 0 );
                synchronized ( body )
                {
                    child = head;
                    while ( child != null )
                    {
                        if ( child instanceof Element )
                        {
                            if ( child != body )
                                html.insertBefore( newBody, child );
                            else
                                html.replaceChild( newBody, body );
                            return;
                        }
                        child = child.getNextSibling();
                    }
                    html.appendChild( newBody );
                }
                return;
            }
            // BODY does not exist, place it in the HTML element
            // right after the HEAD.
            html.appendChild( newBody );
        }
    }
}
 
开发者ID:MaTriXy,项目名称:xerces-for-android,代码行数:49,代码来源:HTMLDocumentImpl.java


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