1 16 17 package org.apache.xerces.dom; 18 19 import org.w3c.dom.DocumentFragment ; 20 import org.w3c.dom.Node ; 21 import org.w3c.dom.Text ; 22 23 65 public class DocumentFragmentImpl 66 extends ParentNode 67 implements DocumentFragment { 68 69 73 74 static final long serialVersionUID = -7596449967279236746L; 75 76 80 81 public DocumentFragmentImpl(CoreDocumentImpl ownerDoc) { 82 super(ownerDoc); 83 } 84 85 86 public DocumentFragmentImpl() {} 87 88 92 96 public short getNodeType() { 97 return Node.DOCUMENT_FRAGMENT_NODE; 98 } 99 100 101 public String getNodeName() { 102 return "#document-fragment"; 103 } 104 105 110 public void normalize() { 111 if (isNormalized()) { 113 return; 114 } 115 if (needsSyncChildren()) { 116 synchronizeChildren(); 117 } 118 ChildNode kid, next; 119 120 for (kid = firstChild; kid != null; kid = next) { 121 next = kid.nextSibling; 122 123 if ( kid.getNodeType() == Node.TEXT_NODE ) 129 { 130 if ( next!=null && next.getNodeType() == Node.TEXT_NODE ) 132 { 133 ((Text )kid).appendData(next.getNodeValue()); 134 removeChild( next ); 135 next = kid; } 137 else 138 { 139 if ( kid.getNodeValue() == null || kid.getNodeValue().length() == 0 ) { 141 removeChild( kid ); 142 } 143 } 144 } 145 146 kid.normalize(); 147 } 148 149 isNormalized(true); 150 } 151 152 } | Popular Tags |