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

hc_textparseintolistofelements

public final class hc_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 "acronym" Element should contain four children with each one of the EntityReferences containing one child.
author
Curt Arnold
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 hc_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, "hc_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/hc_textparseintolistofelements";
   
public static voidmain(java.lang.String[] args)
Runs this test from the command line.

param
args command line arguments

        DOMTestCase.doMain(hc_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;
      String value;
      Node grandChild;
      int length;
      java.util.List result = new java.util.ArrayList();
      
      java.util.List expectedNormal = new java.util.ArrayList();
      expectedNormal.add("β");
      expectedNormal.add(" Dallas, ");
      expectedNormal.add("γ");
      expectedNormal.add("\n 98554");
      
      java.util.List expectedExpanded = new java.util.ArrayList();
      expectedExpanded.add("β Dallas, γ\n 98554");
      
      doc = (Document) load("hc_staff", false);
      elementList = doc.getElementsByTagName("acronym");
      addressNode = elementList.item(1);
      childList = addressNode.getChildNodes();
      length = (int) childList.getLength();
      for (int indexN1007C = 0; indexN1007C < childList.getLength(); indexN1007C++) {
          child = (Node) childList.item(indexN1007C);
    value = child.getNodeValue();
      
      if ((value == null)) {
          grandChild = child.getFirstChild();
      assertNotNull("grandChildNotNull", grandChild);
      value = grandChild.getNodeValue();
      result.add(value);
      } else {
          result.add(value);
      }
        
      }
      
      if (equals(1, length)) {
          assertEquals("assertEqCoalescing", expectedExpanded, result);
      } else {
          assertEquals("assertEqNormal", expectedNormal, result);
      }