//**************************************************************************
//
//
//                       National Institute Of Standards and Technology
//                                     DTS Version 1.0
//         
//                                   Element Interface
//**************************************************************************

function Element()
// 
// Driver function that executes each of the tests for the
// Element interface.
//
// Written by:  Mary Brady 5/99
//
{
   var tests = new Array (core0001E(), core0002E(), core0003E(),core0004E(),
                core0005E(), core0006E(), core0007E(), core0008E(),
		core0009E(), core0010E(), core0011E(), core0012E(),
                core0013E(), core0014E(), core0015E(), core0016E(),
 		core0017E(), core0018E(), core0019E(), core0020E(),
 		core0021E(), core0022E(), core0023E(), core0024E(),
 		core0025E(), core0026E(), core0027E(), core0028E(),
 		core0029E(), core0030E());
  
   return tests;
}
//------------------------ test case core-0001E ------------------------
//
// Testing feature - Elements may have attributes associated with them. 
//
// Testing approach - Retrieve the first attribute from the last child of
//                    the first employee and examine its "specified"
//                    attribute.  This test is only intended to show
//                    that Elements can actually have attributes.
//                    This test uses the "getNamedItem(name)" method from 
//                    the NamedNodeMap interface.
//
// Semantic Requirements: 1
//
// Written by:   Carmelo Montanez  4/99
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0001E()
 {
   var computedValue = 0;
   var expectedValue = true;
   var addressElement = "";
   var attrList = "";
   var domesticAttr = "";


   results = new testResults("Core0001E");

   results.description = "Element nodes may have associated attributes.";
//
// Retrieve the "address" element from the first employee.
//
      addressElement = new nodeObject(FIRST,SIXTH);
//
// Access its "domestic" attribute by creating a list of all attributes
// and then retrieving the desired attribute from the list by name. 
//
      attrList = addressElement.node.attributes;
      domesticAttr = attrList.getNamedItem("domestic");
//
// Access its "specified" attribute.
//
      computedValue = domesticAttr.specified;
//
// Write out results 
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}
//------------------------ End test case core-0001E --------------------------
//
//------------------------ test case core-0002E ------------------------
//
// Testing feature - The generic Attribute "attributes" (Node interface) may 
//                   be used to retrieve the set of all attributes of an
//                   element.
//
// Testing approach - Create a list of all the attributes of the last child of
//                    of the first employee by using the generic "attributes"
//                    attribute from the Node interface.  Further the length
//                    of the attribute list is examined.  This test makes
//                    use of the "length" attribute from the NameNodeMap 
//                    interface.
//
// Semantic Requirements: 1, 2 
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0002E()
 {
   var computedValue = 0;
   var expectedValue = 2;
   var addressElement = "";
   var attrList = "";


   results = new testResults("Core0002E");

   results.description = "The generic \"attributes\" (from the Node interface) may " +
                         "be used to retrieve the set of all attributes of an element.";
//
// Retrieve the "address" element from the first employee.
//
      addressElement = new nodeObject(FIRST,SIXTH);
//
// Access its attributes list.
//
      attrList = addressElement.attributes;
//
// Access its "length" attribute.
//
      computedValue = attrList.length;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0002E --------------------------
//
//-------------------------- test case core-0003E ----------------------------
//
// Testing feature - The "tagName" attribute contains the name of the
//                   element. 
//
// Testing approach - Retrieve the third child of the second employee and
//                    examine its "tagName" attribute.  It should return a 
//                    string containing the name of the element ("position",
//                    in this case). 
//
// Semantic Requirements: 3 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0003E()
 {
   var computedValue = "";
   var expectedValue = "position";
   var positionElement = "";


   results = new testResults("Core0003E");

   results.description = "The \"tagName\" of an Element contains the " +
                         "element's name.";
//
// Access its third child of the second employee.
//
      positionElement = new nodeObject(SECOND,THIRD);
//
// Access its "tagName" attribute.
//
      computedValue = positionElement.node.tagName;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0003E --------------------------
//
//-------------------------- test case core-0004E ----------------------------
//
// Testing feature - The "getAttribute(name)" method returns an attribute value
//                   by name. 
//
// Testing approach - Retrieve the the last child of the third employee, then  
//                    invoke its "getAttribute(name)" method.  It should
//                    return the value of the attribute("No", in this case).
//
// Semantic Requirements: 1, 4
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0004E()
 {
   var computedValue = "";
   var expectedValue = "No";
   var addressElement = "";


   results = new testResults("Core0004E");

   results.description = "The \"getAttribute(name)\" method of an Element returns " +
                         "the value of an attribute by name.";
//
// Retrieve the targeted data. 
//
        addressElement = new nodeObject(THIRD,SIXTH);
        computedValue = addressElement.node.getAttribute("street");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0004E --------------------------
//
//-------------------------- test case core-0005E ----------------------------
//
// Testing feature - The "getAttribute(name)" method returns an empty
//                   string if no value was assigned to an attribute and
//                   no default value was given in the DTD file.
//
// Testing approach - Retrieve the the last child of the last employee, then
//                    invoke its "getAttribute(name)" method, where "name" is an
//                    attribute with no specified or DTD default value.  The
//                    "getAttribute(name)" method should return the empty
//                    string.  This method makes use of the 
//                    "createAttribute(newAttr)" method from the Document
//                    interface.
//
// Semantic Requirements: 1, 4, 5 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0005E()
 {
   var computedValue = "";
   var expectedValue = "";
   var addressElement = "";
   var newAttribute = "";


   results = new testResults("Core0005E");

   results.description = "The \"getAttribute(name)\" method of an Element returns " +
                         "the empty string if the attribue does not have a default " +
                         "or specified value.";
//
// Access the sixth child of the last employee.
//
      var newAttribute = createNode(ATTRIBUTE_NODE,"district");
      addressElement = new nodeObject(FOURTH,SIXTH);
//
// Invoke its "setAttributeNode(newAttr)" method where
// newAttr = "newAttribute".  Since no value was specified or given
// by default, the value returned by the "getAttribute(name)" method 
// should be the empty string.
//
      addressElement.node.setAttributeNode(newAttribute);
      computedValue = addressElement.node.getAttribute("district");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0005E --------------------------
//
//-------------------------- test case core-0006E ----------------------------
//
// Testing feature - The "setAttribute(name,value)" method adds a new attribute
//                   to the Element.
//
// Testing approach - Retrieve the last child of the last employee, then
//                    add an attribute to it by invoking its 
//                    "setAttribute(name,value)" method.  It should create 
//                    a "name" attribute with an assigned value equal to 
//                    "value".  
//
// Semantic Requirements: 1, 4, 6 
//
// Last modification date - February 24, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0006E()
 {
   var computedValue = "";
   var addressElement = "";
   var name = "district";
   var expectedValue = "dallas"; 


   results = new testResults("Core0006E");

   results.description = "The \"setAttribute(name,value)\" method of an Element " +
                         "creates an new \"name\" attribute whose value is equal to \"value\".";
//
// Access the last child of the last employee.
//
      addressElement = new nodeObject(FIFTH,SIXTH);
//
// Invoke its "setAttribute(name,value)" method and create a new attribute
//
      addressElement.node.setAttribute(name,expectedValue);
//
// This Element should now have a new attribute that we can be retrieved
// by name. 
//
      computedValue = addressElement.node.getAttribute(name);
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData()

    return results;
}

//------------------------ End test case core-0006E --------------------------
//
//-------------------------- test case core-0007E ----------------------------
//
// Testing feature - The "setAttribute(name,value)" method adds a new attribute
//                   to the Element.  If the "name" is already present, then
//                   its value should be changed to the new one of the
//                   "value" parameter.
//
// Testing approach - Retrieve the last child of the fourth employee,
//                    then add an attribute to it by invoking its
//                    "setAttribute(name,value)" method.  Since the name 
//                    of the used attribute ("street") is already present
//                    in this element, then its value should be
//                    changed to the new one of the "value" parameter.
//
// Semantic Requirements: 1, 4, 7 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0007E()
 {
   var computedValue = "";
   var expectedValue = "Neither";
   var addressElement = "";


   results = new testResults("Core0007E");

   results.description = "The \"setAttribute(name,value)\" method of an Element " +
                         "where the \"name\" attribute is already present in this Element.";
//
// Access the sixth child of the fourth employee.
//
      addressElement = new nodeObject(FOURTH,SIXTH);
//
// Invoke its "setAttribute(name,value)" method where name = "street"
// and value = "Neither".
//
      addressElement.node.setAttribute("street","Neither");
//
// The "street" attribute should now have a value of "Neither" 
//
      computedValue = addressElement.node.getAttribute("street");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0007E --------------------------
//
//-------------------------- test case core-0008E ----------------------------
//
// Testing feature - The "removeAttribute(name)" removes an attribute
//                   by name.  If the removed attribute is known to have a
//                   default value, an attribute immediately appears 
//                   containing the default value.
//
// Testing approach - Retrieve the attribute named "street" from the last
//                    child of the fourth employee, then remove the "street"
//                    attribute by invoking its "removeAttribute(name) method.
//                    The "street" attribute has a default value defined in the 
//                    DTD file, that value should immediately replace the 
//                    old value.   
//
// Semantic Requirements: 1, 8 
//
// Last modification date - November 23, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0008E()
 {
   var computedValue = "";
   var expectedValue = "Yes";
   var addressElement = "";
   var streetAttr = "";


   results = new testResults("Core0008E");

   results.description = "The \"removeAttribute(name)\" method of an Element " +
                         "removes the \"name\" attribute and restores any " +
                         "known default values.";
//
// Access the last child of the fourth employee.
//
       addressElement = new nodeObject(FOURTH,SIXTH);
//
// Invoke its "removeAttribute(name)" method where name = "street"
//
      addressElement.node.removeAttribute("street");
//
// Now access that attribute.
//
      streetAttr = addressElement.node.getAttribute("street");
//
// The "street" attribute should now have a default values 
//
      computedValue = addressElement.node.getAttribute("street");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0008E --------------------------
//
//-------------------------- test case core-0009E ----------------------------
//
// Testing feature - The "getAttributeNode(name)" retrieves an attribute
//                   node by name.  
//
// Testing approach - Retrieve the attribute named "domestic" from the last 
//                    child of the first employee.  Since the method returns
//                    an Attr object, its name attribute can be examined to 
//                    ensure the proper attribute was retrieved.
//
// Semantic Requirements: 1, 9 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0009E()
 {
   var computedValue = "";
   var expectedValue = "domestic";
   var addressElement = "";
   var domesticAttrNode = "";


   results = new testResults("Core0009E");

   results.description = "The \"getAttributeNode(name)\" method of an Element " +
                         "returns the \"name\" Attr node.";
//
// Access the last child of the first employee.
//
      addressElement = new nodeObject(FIRST,SIXTH);
//
// Invoke its "getAttributeNode(name)" method where name = "domestic"
// and create an Attr object.  
//
      domesticAttrNode = addressElement.node.getAttributeNode("domestic");
//
// Now access the "name" attribute of that Attr node.  Since the "domestic"
// attribute was retrieved, the name of the Attr node should also be
// "domestic". 
//
      computedValue = domesticAttrNode.name;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0009E --------------------------
//
//-------------------------- test case core-00010E ----------------------------
//
// Testing feature - The "getAttributeNode(name)" retrieves an attribute
//                   node by name.  It should return null if the "name" 
//                   attribute does not exist.
//
// Testing approach - Retrieve the last child of the first employee and 
//                    attempt to retrieve a non-existing attribute.
//                    The method should return null.  The non-existing
//                    attribute to be used is "invalidAttribute".
//
// Semantic Requirements: 1, 10
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0010E()
 {
   var computedValue = "";
   var expectedValue = null;
   var addressElement = "";


   results = new testResults("Core0010E");

   results.description = "The \"getAttributeNode(name)\" method returns null " +
                         "if the \"name\" attribute does not exist.";
//
// Access the last child of the first employee.
//
      addressElement = new nodeObject(FIRST,SIXTH);
//
// Invoke its "getAttributeNode(name)" method where name = "invalidAttribute"
// This should result in a null value being returned by the method.
//
      computedValue = addressElement.node.getAttributeNode("invalidAttribute");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0010E --------------------------
//
//-------------------------- test case core-0011E ----------------------------
//
// Testing feature - The "setAttributeNode(newAttr)" adds a new attribute
//                   to the Element.
//
// Testing approach - Retrieve the last child of the first employee and
//                    add a new attribute node to it by invoking its 
//                    "setAttributeNode(newAttr)" method.  This test makes 
//                    use of the "createAttribute(name)" method from the 
//                    Document interface.
//
// Semantic Requirements: 1, 11
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0011E()
 {
   var computedValue = "";
   var expectedValue = "";
   var addressElement = "";
   var newAttribute = "";
   var name = "district";

   results = new testResults("Core0011E");

   results.description = "The \"setAttributeNode(newAttr)\" method adds a new " +
                         "attribute node to the element.";
//
// Access the last child of the first employee.
//
      newAttribute = createNode(ATTRIBUTE_NODE,name);
      addressElement = new nodeObject(FIRST,SIXTH);
//
// Invoke its "setAttributeNode(newAttr)" method where 
// newAttr = "newAttribute".  Since no value was specified or given 
// by default, its value should be the empty string. 
//
      addressElement.node.setAttributeNode(newAttribute);
      computedValue = addressElement.node.getAttribute(name);
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0011E --------------------------
//
//-------------------------- test case core-00012E ----------------------------
//
// Testing feature - The "setAttributeNode(newAttr)" method adds a new attribute
//                   to the Element.  If the "newAttr" Attr node is already
//                   present in this element, it should replace the existing
//                   one.
//
// Testing approach - Retrieve the last child of the third employee and
//                    add a new attribute node to it by invoking its
//                    "setAttributeNode(newAttr)" method.  The new attribute 
//                    node to be added is "street", which is already
//                    present in this element.  The method should replace the 
//                    existing Attr node with the new one.  This test make use 
//                    of the "createAttribute(name)" method from the Document
//                    interface.
//
// Semantic Requirements: 1, 12
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0012E()
 {
   var computedValue = "";
   var expectedValue = "";
   var addressElement = "";
   var newAttribute = "";

   results = new testResults("Core0012E");

   results.description = "The \"setAttributeNode(newAttr)\" method when " +
                         "the \"newAttr\" node is already part of this " +
                         "element.  The existing attribute node should be "+
                         "replaced with the new one."; 
//
// Access the last child of the third employee.
//
      newAttribute = createNode(ATTRIBUTE_NODE,"street");  
      addressElement = new nodeObject(THIRD,SIXTH);
//
// Invoke its "setAttributeNode(newAttr)" method where 
// newAttr = "newAttribute".  That attribute is already part of this 
// element.  The existing attribute should be replaced with the new one 
//    (newAttribute).
//
      addressElement.node.setAttributeNode(newAttribute);
      computedValue = addressElement.node.getAttribute("street");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0012E --------------------------
//
//-------------------------- test case core-00013E ----------------------------
//
// Testing feature - If The "setAttributeNode(newAttr)" method replaces 
//                   an existing Attr node with the same name, then it 
//                   should return the previously existing Attr node.
//
// Testing approach - Retrieve the last child of the third employee and add
//                    a new attribute node to it.  The new attribute node to 
//                    be added is "street", which is already present in this
//                    Element.  The method should return the existing Attr 
//                    node(old "street" Attr).  This test make use of the 
//                    "createAttribute(name)" method from the Document 
//                    interface.
//
// Semantic Requirements: 1, 13
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0013E()
 {
   var computedValue = "";
   var expectedValue = "No";
   var addressElement = "";
   var oldStreetAttribute = "";
   var newAttribute = "";

   results = new testResults("Core0013E");

   results.description = "The \"setAttributeNode(newAttr)\" method when the " +
                         "\"newAttr\" attribute node is already present in " +
                         "this element.  The method should return the previously " +
			 "existing Attr node."; 
//
// Access the last child of the third employee.
//
      newAttribute = createNode(ATTRIBUTE_NODE,"street");
      addressElement = new nodeObject(THIRD,SIXTH);
//
// Invoke its "setAttributeNode(newAttr)" method where 
// newAttr was just created with the same name as an already existing
// attribute("street"). The existing attribute should be replaced with the 
// new one and the method should return the existing "street" Attr node.  
//
      oldStreetAttribute = addressElement.node.setAttributeNode(newAttribute);
//
// The "oldStreetAttribute" now contains the old Attr node and its 
// "value" attribute should be available for examination.
//
      computedValue = oldStreetAttribute.value;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0013E --------------------------
//
//-------------------------- test case core-00014E ----------------------------
//
// Testing feature - The "setAttributeNode(newAttr)" method returns the 
//                   null value if no previously existing Attr node with the 
//                   same name was replaced.
//
// Testing approach - Retrieve the last child of the third and add a new 
//                    attribute node to it.  The new attribute node to be 
//                    added is "district", which is not part of this Element.  
//                    The method should return the null value.  This test makes
//                    use of the "createAttribute(name)" method from the
//                    Document interface.
//
// Semantic Requirements: 1, 15
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0014E()
 {
   var computedValue = "";
   var expectedValue = null;
   var addressElement = "";
   var newAttribute = "";

   results = new testResults("Core0014E");

   results.description = "The \"setAttributeNode(newAttr)\" method returns a " +
                         "null value if no previously existing Attr node was replaced.";
//
// Access the sixth child of the third employee.
//
      newAttribute = createNode(ATTRIBUTE_NODE,"district");
      addressElement = new nodeObject(THIRD,SIXTH);
//
// Invoke its "setAttributeNode(newAttr)" method where name = "newAttribute".
// This attribute is not part of this element.  The method should add the
// new Attribute and return a null value.
//
      computedValue = addressElement.node.setAttributeNode(newAttribute);
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0014E --------------------------
//
//-------------------------- test case core-00015E ----------------------------
//
// Testing feature - The "removeAttributeNode(oldAttr)" method removes the 
//                   specified attribute. 
//
// Testing approach - Retrieve the last child of the third employee, add
//                    a new "district" node to it and the try to remove it. 
//                    To verify that the node was removed this test uses the 
//                    "getNamedItem(name)" from the NamedNodeMap interface.   
//                    This test also makes use of the "attributes" attribute 
//                    from the Node interface.
//
// Semantic Requirements: 1, 14
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0015E()
 {
   var computedValue = "";
   var expectedValue = null;
   var addressElement = "";
   var attrList = "";
   var newAttribute = "";
   newAttribute = createNode(ATTRIBUTE_NODE,"district");

   results = new testResults("Core0015E");

   results.description = "The \"removeAttributeNode(oldAttr)\" method removes the " +
                         "specified attribute node.";
//
// Access the sixth child of the third employee and add the new
// attribute to it.
//
      addressElement = new nodeObject(THIRD,SIXTH);
      addressElement.node.setAttributeNode(newAttribute);
//
// Invoke its "removeAttributeNode(oldAttr)" method where 
// name = "newAttribute" and remove that attribute node.
//
      addressElement.node.removeAttributeNode(newAttribute);
//
// To ensure that the "district" attribute was indeed removed, a listing
// of all attributes is created by invoking the "attributes" attribute
// of "addressElement".  After the list is created, we attempt to
// retrieve the "district" element from the list.  A null value should
// be return in its place.
//
       attrList = addressElement.attributes;
       computedValue = attrList.getNamedItem("district");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0015E --------------------------
//
//-------------------------- test case core-00016E ----------------------------
//
// Testing feature - The "removeAttributeNode(oldAttr)" method removes the 
//                   specified attribute node and restore any default values.
//
// Testing approach - Retrieve the last child of the third employee and
//                    remove its "street" Attr node.  Since this node has
//                    default value defined in the DTD file, that default
//                    value should immediately be the new value.  
//
// Semantic Requirements: 1, 15
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0016E()
 {
   var computedValue = "";
   var expectedValue = "Yes";
   var addressElement = "";
   var streetAttr = "";
   var thirdEmployee = "";

   results = new testResults("Core0016E");

   results.description = "The \"removeAttributeNode(oldAttr)\" method removes the " +
                         "specified attribute node and restores any default values.";
//
// Access the sixth child of the third employee.
//
      addressElement = new nodeObject(THIRD,SIXTH);
//
// Create an instance of an Attr object by retrieving the "street"
// attribute node, invoke its "removeAttributeNode(oldAttr)" method
// where name = "streetAttr" and remove that attribute node.  Note that 
// "the removeAttributeNode(oldAttr)" takes an Attr object as its 
// parameter, that is why an Attr object (named "street") is first created. 
//
      streetAttr = addressElement.node.getAttributeNode("street");
      addressElement.node.removeAttributeNode(streetAttr);
//
// Since there is a default value defined for the "street" attribute, it
// should immediately be the new value for that attribute. 
//
       computedValue = addressElement.node.getAttribute("street");
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0016E --------------------------
//
//-------------------------- test case core-00017E ----------------------------
//
// Testing feature - The "removeAttributeNode(oldAttr)" method returns the 
//                   node that was removed.
//
// Testing approach - Retrieve the last child of the third employee and 
//                    remove its "street" Attr node.  The method should 
//                    return the old attribute node.
//
// Semantic Requirements: 1, 16
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0017E()
 {
   var computedValue = "";
   var expectedValue = "No";
   var addressElement = "";
   var streetAttr = "";
   var oldStreetAttribute = "";

   results = new testResults("Core0017E");

   results.description = "The \"removeAttributeNode(oldAttr)\" method returns the "+
                         "removed attribute node.";
//
// Access the sixth child of the third employee.
//
      addressElement = new nodeObject(THIRD,SIXTH);

// create an instance of an Attr object by retrieving the "street"
// attribute node, invoke its "removeAttributeNode(oldAttr)" method
// where name = "streetAttr" and remove that attribute node.  Note that
// "the removeAttributeNode(oldAttr)" takes an Attr object as its
// parameter, that is why an Attr object (named "street") is first created.
//
      streetAttr = addressElement.node.getAttributeNode("street");
      oldStreetAttribute = addressElement.node.removeAttributeNode(streetAttr);
//
// The method should return the removed attribute node.  Its value can then
// be examined.
//
       computedValue = oldStreetAttribute.value;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0017E --------------------------
//
//-------------------------- test case core-00018E ----------------------------
//
// Testing feature - The "getElementsByTagName(name)" method returns a list 
//                   of all descendant Elements with the given tag name.
//
// Testing approach - Get a listing of all the descendant elements of the
//                    root element using the string "employee" as the tag
//                    name.  The  method should return a Node list of length 
//                    equal to 5.  This test makes use of the "length" 
//                    attribute from the NodeList interface.
//
// Semantic Requirements: 1, 17
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0018E()
 {
   var computedValue = "";
   var expectedValue = 5;
   var employeeList = "";
   var docElement = "";

   results = new testResults("Core0018E");

   results.description = "The \"getElementsByTagName(name)\" method returns a "+
                         "NodeList of all descendant elements with the given " +
                         "tag name(method returning a non-empty list)";
//
// get a listing of all the elements that match the tag "employee".
//
       docElement = getRootNode();
       employeeList = docElement.getElementsByTagName("employee");
//
// The method should return a NodeList whose length can then be examined. 
//
       computedValue = employeeList.length;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0018E --------------------------
//
//-------------------------- test case core-00019E ----------------------------
//
// Testing feature - The "getElementsByTagName(name)" returns a list of all
//                   descendant Elements with the given tag name.  Test
//                   for an empty list.
//
// Testing approach - Get a listing of all the descendant elements of the
//                    root element using the string "noMatches" as the tag
//                    name.  The  method should return a NodeList of length
//                    equal to 0 since no descendant elements match the given
//                    tag name.  This test makes use of the "length" attribute
//                    from the NodeList interface.
//
// Semantic Requirements: 1, 17
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0019E()
 {
   var computedValue = "";
   var expectedValue = 0;
   var employeeList = "";
   var docElement = "";

   results = new testResults("Core0019E");

   results.description = "The \"getElementsByTagName(name)\" method returns a "+
                         "NodeList of all descendant elements with the given " +
                         "tag name (method returns an empty list)";
//
// get a listing of all the elements that match the tag "noMatch".
//
       docElement = getRootNode();
       employeeList = docElement.getElementsByTagName("noMatch");
//
// The method should return a NodeList whose length can then be examined.
//
       computedValue = employeeList.length;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0019E --------------------------
//
//-------------------------- test case core-00020E ----------------------------
//
// Testing feature - The "getElementsByTagName(name)" returns a list of all
//                   descendant Elements in the order the children were
//                   encountered in a pre order traversal of the element tree.
//
// Testing approach - Get a listing of all the descendant elements of the
//                    root node using the string "employee" as the tag
//                    name.  The  method should return a Node list of length
//                    equal to 5 in the order the children were encountered.
//                    Item number four in the list is accessed using a 
//                    subscript.  Item number four is itself an Element node
//                    with children and whose first child should be 
//                    "employeeId".
//
// Semantic Requirements: 1, 18 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0020E()
 {
   var computedValue = "";
   var expectedValue = "employeeId";
   var employeeList = "";
   var fourthEmployee = "";
   var docElement = "";

   results = new testResults("Core0020E");

   results.description = "The \"getElementsByTagName(name)\" returns a NodeList " +
                         "of all descendant elements in the order the " +
                         "children were encountered in a preorder traversal " +
                         "of the element tree.";
//
// get a listing of all the elements that match the tag "employee".
//
       docElement = getRootNode();
       employeeList = docElement.getElementsByTagName("employee");

//
// The method should return a NodeList of the children in the order the 
// children were encountered.  Since "employeeList" is a NodeList we should 
// be able to access its elements by using a subscript.  Item number four 
// is itself an Element node with six children and the first child 
// is "employeeId". 
//
       fourthEmployee = employeeList(FOURTH);
       computedValue = fourthEmployee.firstChild.nodeName;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0020E --------------------------
//
//-------------------------- test case core-00021E ----------------------------
//
// Testing feature - The "getElementsByTagName(name)" method may use the 
//                   special value "*" to match all the tags in the element 
//                   tree. 
//
// Testing approach - Get a listing of all the descendant elements of the
//                    last employee by using the special value of "*".  The 
//                    method should return all of the descendant children
//                    (total of 6) in the order the children were encountered.
//
// Semantic Requirements: 1, 19 
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0021E()
 {
   var computedValue = "";
   var expectedValue = "employeeId name position salary gender address ";
   var elementList = "";
   var lastEmployee = "";

   results = new testResults("Core0021E");

   results.description = "The \"getElementsByTagName(name)\" method may use the " +
                         "special value \"*\" to match all the tags in the " +
                         "element tree.";
//
// get a listing of all the descendant elements of the last employee by using
// the special value of "*".
//
       lastEmployee = new nodeObject(FIFTH);
       elementList = lastEmployee.node.getElementsByTagName("*");
//
// Traverse the list.
//
       for (var index = 0;index <= elementList.length - 1;index++)
          computedValue += elementList(index).nodeName+" ";
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    return results;
}

//------------------------ End test case core-0021E --------------------------
//
//-------------------------- test case core-00022E ----------------------------
//
// Testing feature - The "normalize()" method puts all the nodes in the
//                   full depth of the sub-tree underneath this element
//                   into a "normal" form.
//
// Testing approach - Retrieve the third employee and access its second 
//                    child.  This child contains a block of text that spread
//                    accross multiple lines.  The content of the "name" 
//                    child should be parsed and treated as a single Text node.
//
// Semantic Requirements: 1, 20
//
// Last modification date - March 30, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0022E()
 {
   var computedValue = "";
   var expectedValue = "Roger\n Jones";
   var idElement = "";
   var textNode = "";

   results = new testResults("Core0022E");

   results.description = "The \"normalize()\" method puts all the nodes in the " +
                         "full depth of the sub-tree of this element into a normal form.";
//
// The "normalize() method should combine all the contiguous blocks of text
// and form a single "Text" node.  The "nodeValue" of that final Text node
// should be the combination of all continuos blocks of text that do not
// contain any markup language. 
//
       idElement = new nodeObject(THIRD,SECOND);
       idElement.node.normalize();
       textNode = idElement.node.lastChild;
//
// text should be in normal form now
//
       computedValue = textNode.nodeValue;
//
// Write out results
//
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0022E --------------------------
//
//-------------------------- test case core-00023E ---------------------------
//
// Testing feature - The "setAttribute(name,value)" method raises an
//                   INVALID_CHARACTER_ERR DOMException if the specified  
//                   name contains an invalid character.
//
// Testing approach - Retrieve the last child of the first employee
//                    and call its "setAttribute(name,value)" method with
//                    "name" containing an invalid character.
//
// Semantic Requirements: 1, 21
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0023E()
 {
   var computedValue = "";
   var addressElement = "";
   var expectedValue = INVALID_CHARACTER_ERR;

   results = new testResults("Core0023E");

   results.description = "The \"setAttribute(name,value)\" method raises an " +
                         "INVALID_CHARACTER_ERR DOMException if the specified " +
			 "name contains an invalid character.";
//
// Access the "address" element of the first employee. 
//
       addressElement = new nodeObject(FIRST,SIXTH);
//
// Attempt to set an attribute with an invalid character in its name.
//
      try {
         addressElement.node.setAttribute("invalid^Name","thisValue");
      }
      catch(DOMException) {
         computedValue = DOMException.description;
      }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0023E --------------------------
//
//-------------------------- test case core-0024E ----------------------------
//
// Testing feature - The "setAttribute(name,value)" method raises a
//                   NO_MODIFICATION_ALLOWED_ERR DOMException if this 
//                   node is readonly.
//
// Testing approach - Retrieve the Element node inside the Entity node 
//                    named "ent4" and attempt to set an attribute for
//                    it.  Descendants of Entity nodes are readonly nodes
//                    and therefore the desired exception should be raised.
//
// Semantic Requirements: 22
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0024E()
 {
   var computedValue = "";
   var entityNode = "";
   var entityDesc = "";
   var expectedValue = NO_MODIFICATION_ALLOWED_ERR;

   results = new testResults("Core0024E");

   results.description = "The \"setAttribute(name,value)\" method raises a " +
                         "NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly.";

//
// Retreive the targeted data.
//
    entityNode = getEntity("ent4");
    entityDesc = entityNode.firstChild;
//
// Attempt to set an attribute for a readonly node should raise an exception.
//
      try {
          entityDesc.setAttribute("newAttribute","thisValue");
      }
      catch(DOMException) {
        computedValue = DOMException.description;
      }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0024E --------------------------
//
//-------------------------- test case core-00025E ---------------------------
//
// Testing feature - The "removeAttribute(name)" method raises a
//                   NO_MODIFICATION_ALLOWED_ERR DOMException if this
//                   node is readonly.
//
// Testing approach - Retrieve the Element node inside the Entity node
//                    named "ent4" and attempt to remove an attribute from
//                    it.  Descendants of Entity nodes are readonly nodes
//                    and therefore the desired exception should be raised.
//
// Semantic Requirements: 23
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0025E()
 {
   var computedValue = "";
   var entityNode = "";
   var entityDesc = "";
   var expectedValue = NO_MODIFICATION_ALLOWED_ERR;

   results = new testResults("Core0025E");

   results.description = "The \"removeAttribute(name)\" method raises a " +
                         "NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly.";
//
// Retrieve the targeted data.
//
     entityNode = getEntity("ent4");
     entityDesc = entityNode.firstChild;
//
// Attempt to set an attribute for a readonly node should raise an exception.
//
     try {
          entityDesc.removeAttribute("attr1");
     }
     catch(DOMException) {
          computedValue = DOMException.description;
     }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0025E --------------------------
//
//-------------------------- test case core-00026E ---------------------------
//
// Testing feature - The "setAttributeNode(newAttr)" method raises a
//                   NO_MODIFICATION_ALLOWED_ERR DOMException if this
//                   node is readonly.
//
// Testing approach - Retrieve the Element node inside the Entity node
//                    named "ent4" and attempt to add a newly created Attr 
//                    node to it.  Descendants of Entity nodes are readonly 
//                    nodes and therefore the desired exception should be
//                    raised.
//
// Semantic Requirements: 24
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0026E()
 {
   var computedValue = "";
   var entityNode = "";
   var entityDesc = "";
   var newAttr = createNode(ATTRIBUTE_NODE,"newAttribute");
   expectedValue = NO_MODIFICATION_ALLOWED_ERR;

   results = new testResults("Core0026E");

   results.description = "The \"setAttributeNode(newAttr)\" method raises a " +
                         "NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly.";
//
// Retrieve targeted data
//
     entityNode = getEntity("ent4");
     entityDesc = entityNode.firstChild;
//
// Attempt to set an attribute for a readonly node should raise an exception.
//
       try {
          entityDesc.setAttributeNode(newAttr);
       }
       catch(DOMException) {
          computedValue = DOMException.description;
       }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0026E --------------------------
//
//-------------------------- test case core-00027E ---------------------------
//
// Testing feature - The "removeAttributeNode(newAttr)" method raises a
//                   NO_MODIFICATION_ALLOWED_ERR DOMException if this
//                   node is readonly.
//
// Testing approach - Retrieve the Element node inside the Entity node
//                    named "ent4" and attempt to remove its "attr1"
//                    attribute.  Descendants of Entity nodes are readonly
//                    nodes and therefore the desired exception should be
//                    raised.
//
// Semantic Requirements: 25
//
// Last modification date - July  8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0027E()
 {
   var computedValue = "";
   var entityNode = "";
   var entityDesc = "";
   var oldAttribute = "";
   var expectedValue = NO_MODIFICATION_ALLOWED_ERR;

   results = new testResults("Core0027E");

   results.description = "The \"removeAttributeNode(newAttr)\" method raises a " +
                         "NO_MODIFICATION_ALLOWED_ERR DOMException if the node is readonly.";
//
// Get an instance of an attribute node and retrieve targeted data.
//
      entityNode = getEntity("ent4");
      entityDesc = entityNode.firstChild;
      oldAttribute = entityNode.firstChild.getAttributeNode("attr1");
//
// Attempt to set remove an attribute node from a readonly node (lastChild).  
// Should raise an exception. 
//
       try {
          entityDesc.removeAttributeNode(oldAttribute);
       }
       catch(DOMException) {
          computedValue = DOMException.description;
       }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0027E --------------------------
//
//-------------------------- test case core-00028E ---------------------------
//
// Testing feature - The "setAttributeNode(newAttr)" method raises a
//                   WRONG_DOCUMENT_ERR DOMException if the "newAttr" was 
//                   created from a different document than the one that
//                   created this document. 
//
// Testing approach - Retrieve the last employee and attempt to set
//                    a new attribute node for its "employee" element.
//                    The new attribute was created from a document 
//                    other than the one that crated this element,
//                    therefore the desired exception should be raised. 
//                    This test uses the "createAttribute(newAttr)" method
//                    from the Document interface.
//
// Semantic Requirements: 26
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0028E()
 {
   var addressElement = "";
   var computedValue = "";
   var newAttr = ""
   var expectedValue = WRONG_DOCUMENT_ERR;

   results = new testResults("Core0028E");

   results.description = "The \"setAttributeNode(newAttr)\" method raises a " +
                         "WRONG_DOCUMENT_ERR DOMException if \"newAttr\" was created " +
			 "from a different document than the one who created this node.";
//
// Access the address Element of the last employee and attempt to set 
// a new attribute node. 
//
       newAttr = getOtherDOMDocument().createAttribute("newAttribute");
       addressElement = new nodeObject(FIFTH,SIXTH);
//
// The new attribute was created from a different document and therefore 
// an exception should be raised.
//
       try {
          addressElement.node.setAttributeNode(newAttr);
       }
       catch(DOMException) {
         computedValue = DOMException.description;
       }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0028E --------------------------
//
//-------------------------- test case core-00029E ---------------------------
//
// Testing feature - The "setAttributeNode(newAttr)" method raises an
//                   INUSE_ATTRIBUTE_ERR DOMException if the "newAttr"
//                   attribute is already an attribute of another element. 
//
// Testing approach - Retrieve the last employee and attempt to set an
//                    attribute node to one of its children that
//                    already exist in another children.  The attribute
//                    node used is "street", which already exist in the
//                    "address" element.  An instance of that attribute
//                    node is first retrived from the "address" element and
//                    then attempted to be set in the "employeeId" element.  
//                    This should cause the intended exception to be raised.
//
// Semantic Requirements: 27
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0029E()
 {
   var computedValue = "";
   var employeeIdElement = "";
   var addressElement = "";
   var newAttribute = ""; 
   var expectedValue = INUSE_ATTRIBUTE_ERR;

   results = new testResults("Core0029E");

   results.description = "The \"setAttributeNode(newAttr)\" method raises an "+
                         "INUSE_ATTRIBUTE_ERR DOMException if \"newAttr\" attribute "+
                         "is already being used by another element.";
//
// Retrieve an already existing attribute from the "address" element.
// 
     addressElement =  new nodeObject(FIFTH,SIXTH);
     newAttribute = addressElement.node.getAttributeNode("street");
//
// Access the "employeeId" element of the last employee.
//
      employeeIdElement = new nodeObject(FIFTH,FIRST);
//
// Attempt to set an attribute node with an already existing attribute node  
// in another element.
//
      try {
         employeeIdElement.node.setAttributeNode(newAttribute);
      }
      catch(DOMException) { 
         computedValue = DOMException.description;
      }
    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0029E -------------------------
//
//-------------------------- test case core-0030E ---------------------------
//
// Testing feature - The "removeAttributeNode(oldAttr)" method raises a 
//                   NOT_FOUND_ERR DOMException if the "oldAttr" attribute
//                   is not an attribute of the element.
//
// Testing approach - Retrieve the last employee and attempt to remove
//                    a non existing attribute node.   This should cause 
//                    the intended exception be raised.  This test makes use
//                    of the "createAttribute(name)" method from the
//                    Document interface.
//
// Semantic Requirements: 28
//
// Last modification date - July 8, 1999
//
// Written by: Carmelo Montanez
// Modified by:  Mary Brady  5/99
//	- added support for testResults object
//	- integrated with driver routines
//----------------------------------------------------------------------------

 function core0030E()
 {
   var computedValue = "";
   var addressElement = "";
   var oldAttribute = createNode(ATTRIBUTE_NODE,"oldAttribute");
   var expectedValue = NOT_FOUND1_ERR;

   results = new testResults("Core0030E");

   results.description = "The \"removeAttributeNode(oldAttr)\" method raises a " +
                         "NOT_FOUND_ERR DOMException if \"oldAttr\" attribute " +
			 "is not an attribute of the element.";
//
// Access the "address" element of the last employee.
//
      addressElement = new nodeObject(FIFTH,SIXTH);
//
// Attempt to remove a non-existing attribute. Should raise exception.
//
       try {
          addressElement.node.removeAttributeNode(oldAttribute);
       }
       catch(DOMException) {
          computedValue = DOMException.description;
       }

    results.expected = expectedValue;
    results.actual = computedValue;

    resetData();

    return results;
}

//------------------------ End test case core-0030E --------------------------