Main Page Packages Class Hierarchy Compound List File List Compound Members

# elementcreatenewattribute Class Reference

Inherits DOMTestCase.

List of all members.

## Public Methods
| elementcreatenewattribute (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.

Retrieve first address element 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.

Author:
  NIST , Mary Brady

See also:
  http://www.w3.org/TR/1998/REC-DOM-Level-1-19981001/level-one-core#ID-887236154

Definition at line 46 of file elementcreatenewattribute.java.

## Constructor & Destructor Documentation

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

| Definition at line 48 of file elementcreatenewattribute.java.
    00049  {
    00050       super(factory);
    00051
    00052    }

## Member Function Documentation

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

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

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

| Definition at line 77 of file elementcreatenewattribute.java. References DOMTestCase::doMain().
    00077                                           {
    00078         DOMTestCase.doMain(elementcreatenewattribute.class,args);
    00079    }

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

| Reimplemented from DOMTestCase. Definition at line 54 of file elementcreatenewattribute.java. References DOMTestCase::assertEquals(), DOMTestCase::assertNotNull(), DOMTestCase::assertNull(), and DOMTest::load().
    00054                                                     {
    00055       Document doc;
    00056       NodeList elementList;
    00057       Element testAddress;
    00058       Attr newAttribute;
    00059       Attr oldAttr;
    00060       Attr districtAttr;
    00061       String attrVal;
    00062       doc = load("staff");
    00063       elementList = doc.getElementsByTagName("address");
    00064       testAddress = (Element)elementList.item(0);
    00065       newAttribute = doc.createAttribute("district");
    00066       oldAttr = testAddress.setAttributeNode(newAttribute);
    00067       assertNull("old_attr_doesnt_exist",oldAttr);
    00068       districtAttr = testAddress.getAttributeNode("district");
    00069       assertNotNull("new_district_accessible",districtAttr);
    00070       attrVal = testAddress.getAttribute("district");
    00071       assertEquals("attr_value","",attrVal);
    00072
    00073    }

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

- elementcreatenewattribute.java