00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 package org.w3c.domts.level1.core;
00021
00022 import org.w3c.dom.*;
00023 import org.w3c.dom.html.*;
00024 import org.w3c.dom.events.*;
00025 import org.w3c.domts.*;
00026 import javax.xml.parsers.*;
00027 import java.util.*;
00028
00029
00030
00046 public class nodeappendchilddocfragment extends DOMTestCase {
00047
00048 public nodeappendchilddocfragment(DOMTestDocumentBuilderFactory factory)
00049 {
00050 super(factory);
00051
00052 }
00053
00054 public void runTest() throws java.lang.Throwable {
00055 Document doc;
00056 NodeList elementList;
00057 Node employeeNode;
00058 NodeList childList;
00059 DocumentFragment newdocFragment;
00060 Node newChild1;
00061 Node newChild2;
00062 Node child;
00063 String childName;
00064 List result = new ArrayList();
00065
00066 Node appendedChild;
00067 List expectedWithWhitespace = new ArrayList();
00068 expectedWithWhitespace.add("#text");
00069 expectedWithWhitespace.add("employeeId");
00070 expectedWithWhitespace.add("#text");
00071 expectedWithWhitespace.add("name");
00072 expectedWithWhitespace.add("#text");
00073 expectedWithWhitespace.add("position");
00074 expectedWithWhitespace.add("#text");
00075 expectedWithWhitespace.add("salary");
00076 expectedWithWhitespace.add("#text");
00077 expectedWithWhitespace.add("gender");
00078 expectedWithWhitespace.add("#text");
00079 expectedWithWhitespace.add("address");
00080 expectedWithWhitespace.add("#text");
00081 expectedWithWhitespace.add("newChild1");
00082 expectedWithWhitespace.add("newChild2");
00083
00084 List expectedWithoutWhitespace = new ArrayList();
00085 expectedWithoutWhitespace.add("employeeId");
00086 expectedWithoutWhitespace.add("name");
00087 expectedWithoutWhitespace.add("position");
00088 expectedWithoutWhitespace.add("salary");
00089 expectedWithoutWhitespace.add("gender");
00090 expectedWithoutWhitespace.add("address");
00091 expectedWithoutWhitespace.add("newChild1");
00092 expectedWithoutWhitespace.add("newChild2");
00093
00094 doc = load("staff");
00095 elementList = doc.getElementsByTagName("employee");
00096 employeeNode = elementList.item(1);
00097 childList = employeeNode.getChildNodes();
00098 newdocFragment = doc.createDocumentFragment();
00099 newChild1 = doc.createElement("newChild1");
00100 newChild2 = doc.createElement("newChild2");
00101 appendedChild = newdocFragment.appendChild(newChild1);
00102 appendedChild = newdocFragment.appendChild(newChild2);
00103 appendedChild = employeeNode.appendChild(newdocFragment);
00104 for(int _index = 0; _index < childList.getLength();_index++) {
00105 child = ( Node ) childList.item(_index);
00106 childName = child.getNodeName();
00107 result.add(childName);
00108
00109 }
00110
00111 if(
00112 isIgnoringElementContentWhitespace()
00113 ) {
00114 assertEquals("nodeNamesNoWhitespace",expectedWithoutWhitespace,result);
00115
00116 }
00117
00118 else {
00119 assertEquals("nodeNamesWithWhitespace",expectedWithWhitespace,result);
00120
00121 }
00122
00123 }
00124 public String getTargetURI() {
00125 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/nodeappendchilddocfragment";
00126 }
00127 public static void main(String[] args) {
00128 DOMTestCase.doMain(nodeappendchilddocfragment.class,args);
00129 }
00130 }