本文整理汇总了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 );
}
示例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 );
}
示例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);
}
示例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;
}
示例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;
}
示例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 );
}
}
}