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


Java Node.normalize方法代码示例

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


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

示例1: appendChildren

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * Appends the child nodes of another propbag into the node located by
 * szNodeName
 * 
 * @param szNodeName The path to insert into
 * @param xml The propbag that we want the children of
 */
public void appendChildren(final String szNodeName, final PropBagEx xml)
{
	checkNotAttribute(szNodeName);

	ensureRoot();
	xml.ensureRoot();
	Node oNode = getNodeHelper(szNodeName, false, false);
	if( oNode == null )
	{
		createNode(szNodeName, BLANK);
		oNode = getNodeHelper(szNodeName, false, false);
	}

	final Document doc = oNode.getOwnerDocument();
	Node child = xml.m_elRoot.getFirstChild();
	while( child != null )
	{
		oNode.appendChild(importNode(doc, child, true));
		child = child.getNextSibling();
	}

	// we might have pushed two text nodes together, normalise it
	oNode.normalize();
}
 
开发者ID:equella,项目名称:Equella,代码行数:32,代码来源:PropBagEx.java

示例2: endElement

import org.w3c.dom.Node; //导入方法依赖的package包/类
@Override
public void endElement(final String uri, final String localName, final String qName) {
    final Node last = this.myElements.removeLast();
    this.markLocation(last, END_LOC);

    if (this.myElements.isEmpty()) {
        last.normalize();
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:10,代码来源:ValidateContextImpl.java

示例3: normalize

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * In "normal form" (as read from a source file), there will never be two
 * Text children in succession. But DOM users may create successive Text
 * nodes in the course of manipulating the document. Normalize walks the
 * sub-tree and merges adjacent Texts, as if the DOM had been written out
 * and read back in again. This simplifies implementation of higher-level
 * functions that may want to assume that the document is in standard form.
 * <p>
 * To normalize a Document, normalize its top-level Element child.
 * <p>
 * As of PR-DOM-Level-1-19980818, CDATA -- despite being a subclass of
 * Text -- is considered "markup" and will _not_ be merged either with
 * normal Text or with other CDATASections.
 */
public void normalize() {
    // No need to normalize if already normalized.
    if (isNormalized()) {
        return;
    }
    if (needsSyncChildren()) {
        synchronizeChildren();
    }
    ChildNode kid, next;
    for (kid = firstChild; kid != null; kid = next) {
        next = kid.nextSibling;

        // If kid is a text node, we need to check for one of two
        // conditions:
        //   1) There is an adjacent text node
        //   2) There is no adjacent text node, but kid is
        //      an empty text node.
        if ( kid.getNodeType() == Node.TEXT_NODE )
        {
            // If an adjacent text node, merge it with kid
            if ( next!=null && next.getNodeType() == Node.TEXT_NODE )
            {
                ((Text)kid).appendData(next.getNodeValue());
                removeChild( next );
                next = kid; // Don't advance; there might be another.
            }
            else
            {
                // If kid is empty, remove it
                if ( kid.getNodeValue() == null || kid.getNodeValue().length() == 0 ) {
                    removeChild( kid );
                }
            }
        }

        // Otherwise it might be an Element, which is handled recursively
        else if (kid.getNodeType() == Node.ELEMENT_NODE) {
            kid.normalize();
        }
    }

    // We must also normalize all of the attributes
    if ( attributes!=null )
    {
        for( int i=0; i<attributes.getLength(); ++i )
        {
            Node attr = attributes.item(i);
            attr.normalize();
        }
    }

    // changed() will have occurred when the removeChild() was done,
    // so does not have to be reissued.

    isNormalized(true);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:71,代码来源:ElementImpl.java

示例4: normalize

import org.w3c.dom.Node; //导入方法依赖的package包/类
/**
 * In "normal form" (as read from a source file), there will never be two
 * Text children in succession. But DOM users may create successive Text
 * nodes in the course of manipulating the document. Normalize walks the
 * sub-tree and merges adjacent Texts, as if the DOM had been written out
 * and read back in again. This simplifies implementation of higher-level
 * functions that may want to assume that the document is in standard form.
 * <p>
 * To normalize a Document, normalize its top-level Element child.
 * <p>
 * As of PR-DOM-Level-1-19980818, CDATA -- despite being a subclass of Text
 * -- is considered "markup" and will _not_ be merged either with normal
 * Text or with other CDATASections.
 */
public void normalize() {
    // No need to normalize if already normalized.
    if (isNormalized()) {
        return;
    }
    if (needsSyncChildren()) {
        synchronizeChildren();
    }
    ChildNode kid, next;
    for (kid = firstChild; kid != null; kid = next) {
        next = kid.nextSibling;

        // If kid is a text node, we need to check for one of two
        // conditions:
        //   1) There is an adjacent text node
        //   2) There is no adjacent text node, but kid is
        //      an empty text node.
        if (kid.getNodeType() == Node.TEXT_NODE) {
            // If an adjacent text node, merge it with kid
            if (next != null && next.getNodeType() == Node.TEXT_NODE) {
                ((Text) kid).appendData(next.getNodeValue());
                removeChild(next);
                next = kid; // Don't advance; there might be another.
            } else {
                // If kid is empty, remove it
                if (kid.getNodeValue() == null || kid.getNodeValue().length() == 0) {
                    removeChild(kid);
                }
            }
        } // Otherwise it might be an Element, which is handled recursively
        else if (kid.getNodeType() == Node.ELEMENT_NODE) {
            kid.normalize();
        }
    }

    // We must also normalize all of the attributes
    if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); ++i) {
            Node attr = attributes.item(i);
            attr.normalize();
        }
    }

    // changed() will have occurred when the removeChild() was done,
    // so does not have to be reissued.
    isNormalized(true);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:62,代码来源:ElementImpl.java


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