FileDocCategorySizeDatePackage
textparseintolistofelements.javaAPI DocAndroid 1.5 API4479Wed May 06 22:41:04 BST 2009org.w3c.domts.level1.core

textparseintolistofelements

public final class textparseintolistofelements extends org.w3c.domts.DOMTestCase
Retrieve the textual data from the last child of the second employee. That node is composed of two EntityReference nodes and two Text nodes. After the content node is parsed, the "address" Element should contain four children with each one of the EntityReferences containing one child.
author
NIST
author
Mary Brady
see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-1451460987
see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-11C98490
see
http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-745549614

Fields Summary
Constructors Summary
public textparseintolistofelements(org.w3c.domts.DOMTestDocumentBuilderFactory factory)
Constructor.

param
factory document factory, may not be null
throws
org.w3c.domts.DOMTestIncompatibleException Thrown if test is not compatible with parser configuration

      super(factory);

    //
    //   check if loaded documents are supported for content type
    //
    String contentType = getContentType();
    preload(contentType, "staff", false);
    
Methods Summary
public java.lang.StringgetTargetURI()
Gets URI that identifies the test.

return
uri identifier of test

      return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/textparseintolistofelements";
   
public static voidmain(java.lang.String[] args)
Runs this test from the command line.

param
args command line arguments

        DOMTestCase.doMain(textparseintolistofelements.class, args);
   
public voidrunTest()
Runs the test case.

throws
Throwable Any uncaught exception causes test to fail

      Document doc;
      NodeList elementList;
      Node addressNode;
      NodeList childList;
      Node child;
      int length;
      String value;
      Node grandChild;
      java.util.List result = new java.util.ArrayList();
      
      java.util.List expectedNormal = new java.util.ArrayList();
      expectedNormal.add("1900 Dallas Road");
      expectedNormal.add(" Dallas, ");
      expectedNormal.add("Texas");
      expectedNormal.add("\n 98554");
      
      java.util.List expectedExpanded = new java.util.ArrayList();
      expectedExpanded.add("1900 Dallas Road Dallas, Texas\n 98554");
      
      doc = (Document) load("staff", false);
      elementList = doc.getElementsByTagName("address");
      addressNode = elementList.item(1);
      childList = addressNode.getChildNodes();
      length = (int) childList.getLength();
      for (int indexN1007F = 0; indexN1007F < childList.getLength(); indexN1007F++) {
          child = (Node) childList.item(indexN1007F);
    value = child.getNodeValue();
      
      if ((value == null)) {
          grandChild = child.getFirstChild();
      assertNotNull("grandChildNotNull", grandChild);
      value = grandChild.getNodeValue();
      result.add(value);
      } else {
          result.add(value);
      }
        
      }
      
      if (equals(4, length)) {
          assertEquals("assertEqNormal", expectedNormal, result);
      } else {
          assertEquals("assertEqCoalescing", expectedExpanded, result);
      }