Main Page Packages Class Hierarchy Compound List File List Compound Members

# elementreplaceexistingattribute Class Reference

Inherits DOMTestCase.

List of all members.

## Public Methods
| elementreplaceexistingattribute (DOMTestDocumentBuilderFactory factory)
void | runTest () throws java.lang.Throwable
String | getTargetURI ()
## Static Public Methods
void | main (String[] args)

## Detailed Description

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.

Retrieve the last child of the third employee and add a new attribute node by invoking the "setAttributeNode(new Attr)" 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 uses the "createAttribute(name)" method from the Document interface.

Author:
  NIST , Mary Brady

Definition at line 49 of file elementreplaceexistingattribute.java.

## Constructor & Destructor Documentation

elementreplaceexistingattribute::elementreplaceexistingattribute | ( | DOMTestDocumentBuilderFactory | factory | ) | `[inline]`

| Definition at line 51 of file elementreplaceexistingattribute.java.
    00052  {
    00053       super(factory);
    00054
    00055    }

## Member Function Documentation

String elementreplaceexistingattribute::getTargetURI | ( |  | ) | `[inline, virtual]`

| Reimplemented from DOMTest. Definition at line 73 of file elementreplaceexistingattribute.java.
    00073                                 {
    00074       return "http://www.w3.org/2001/DOM-Test-Suite/level1/core/elementreplaceexistingattribute";
    00075    }

void elementreplaceexistingattribute::main | ( | String | args[] | ) | `[inline, static]`

| Definition at line 76 of file elementreplaceexistingattribute.java. References DOMTestCase::doMain().
    00076                                           {
    00077         DOMTestCase.doMain(elementreplaceexistingattribute.class,args);
    00078    }

void elementreplaceexistingattribute::runTest | ( |  | ) | `[inline, virtual]`

| Reimplemented from DOMTestCase. Definition at line 57 of file elementreplaceexistingattribute.java. References DOMTestCase::assertEquals(), and DOMTest::load().
    00057                                                     {
    00058       Document doc;
    00059       NodeList elementList;
    00060       Element testEmployee;
    00061       Attr newAttribute;
    00062       String name;
    00063       Attr setAttr;
    00064       doc = load("staff");
    00065       elementList = doc.getElementsByTagName("address");
    00066       testEmployee = (Element)elementList.item(2);
    00067       newAttribute = doc.createAttribute("street");
    00068       setAttr = testEmployee.setAttributeNode(newAttribute);
    00069       name = testEmployee.getAttribute("street");
    00070       assertEquals("elementReplaceExistingAttributeAssert","",name);
    00071
    00072    }

The documentation for this class was generated from the following file:

- elementreplaceexistingattribute.java