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
00050 public class textparseintolistofelements extends DOMTestCase {
00051
00052 public textparseintolistofelements(DOMTestDocumentBuilderFactory factory)
00053 {
00054 super(factory);
00055
00056 }
00057
00058 public void runTest() throws java.lang.Throwable {
00059 Document doc;
00060 NodeList elementList;
00061 Node addressNode;
00062 NodeList childList;
00063 Node child;
00064 String value;
00065 Node grandChild;
00066 List result = new ArrayList();
00067
00068 List expectedNormal = new ArrayList();
00069 expectedNormal.add("1900 Dallas Road");
00070 expectedNormal.add(" Dallas, ");
00071 expectedNormal.add("Texas");
00072 expectedNormal.add("\n 98554");
00073
00074 List expectedExpanded = new ArrayList();
00075 expectedExpanded.add("1900 Dallas Road Dallas, Texas\n 98554");
00076
00077 doc = load("staff");
00078 elementList = doc.getElementsByTagName("address");
00079 addressNode = elementList.item(1);
00080 childList = addressNode.getChildNodes();
00081 for(int _index = 0; _index < childList.getLength();_index++) {
00082 child = ( Node ) childList.item(_index);
00083 value = child.getNodeValue();
00084
00085 if(
00086
00087 (value == null)
00088
00089 ) {
00090 grandChild = child.getFirstChild();
00091 value = grandChild.getNodeValue();
00092 result.add(value);
00093
00094 }
00095
00096 else {
00097 result.add(value);
00098
00099 }
00100
00101 }
00102
00103 if(
00104 isExpandEntityReferences()
00105 ) {
00106 assertEquals("assertEqCoalescing",expectedExpanded,result);
00107
00108 }
00109
00110 else {
00111 assertEquals("assertEqNormal",expectedNormal,result);
00112
00113 }
00114
00115 }
00116 public String getTargetURI() {
00117 return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textparseintolistofelements";
00118 }
00119 public static void main(String[] args) {
00120 DOMTestCase.doMain(textparseintolistofelements.class,args);
00121 }
00122 }