本文整理匯總了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();
}
示例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);
}
示例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);
}