NamedNodeMapGetNamedItemNSpublic final class NamedNodeMapGetNamedItemNS extends DOMTestCase Using the method getNamedItemNS, retreive the entity "ent1" and notation
"notation1" from a NamedNodeMap of this DocumentTypes entities and notations.
Both should be null since entities and notations are not namespaced. |
Fields Summary |
---|
DOMDocumentBuilderFactory | factory | DocumentBuilder | builder |
Methods Summary |
---|
protected void | setUp()
super.setUp();
try {
factory = new DOMDocumentBuilderFactory(DOMDocumentBuilderFactory
.getConfiguration2());
builder = factory.getBuilder();
} catch (Exception e) {
fail("Unexpected exception" + e.getMessage());
}
| protected void | tearDown()
factory = null;
builder = null;
super.tearDown();
| public void | testGetNamedItemNS2()Runs the test case.
Document doc;
NamedNodeMap attributes;
Node element;
Attr attribute;
NodeList elementList;
String attrName;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov",
"address");
element = elementList.item(1);
attributes = element.getAttributes();
attribute = (Attr) attributes.getNamedItemNS("http://www.nist.gov",
"domestic");
attrName = attribute.getNodeName();
assertEquals("namednodemapgetnameditemns02", "emp:domestic", attrName);
| public void | testGetNamedItemNS3()
Document doc;
NamedNodeMap attributes;
Node element;
Attr attribute;
Attr newAttr1;
Attr newAttr2;
String attrName;
doc = (Document) load("staffNS", builder);
element = doc.createElementNS("http://www.w3.org/DOM/Test", "root");
newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "L1:att");
((Element) /* Node */element).setAttributeNodeNS(newAttr1);
newAttr2 = doc.createAttributeNS("http://www.w3.org/DOM/L2", "L2:att");
((Element) /* Node */element).setAttributeNodeNS(newAttr2);
attributes = element.getAttributes();
attribute = (Attr) attributes.getNamedItemNS(
"http://www.w3.org/DOM/L2", "att");
attrName = attribute.getNodeName();
assertEquals("namednodemapgetnameditemns03", "L2:att", attrName);
| public void | testGetNamedItemNS4()
Document doc;
NamedNodeMap attributes;
Element element;
Attr attribute;
Attr newAttr1;
NodeList elementList;
String attrName;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("*", "address");
element = (Element) elementList.item(1);
newAttr1 = doc.createAttributeNS("http://www.w3.org/DOM/L1", "street");
element.setAttributeNodeNS(newAttr1);
attributes = element.getAttributes();
attribute = (Attr) attributes.getNamedItemNS(
"http://www.w3.org/DOM/L1", "street");
attrName = attribute.getNodeName();
assertEquals("namednodemapgetnameditemns04", "street", attrName);
| public void | testGetNamedItemNS5()
Document doc;
NamedNodeMap attributes;
Node element;
Attr attribute;
NodeList elementList;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("*", "address");
element = elementList.item(1);
attributes = element.getAttributes();
attribute = (Attr) attributes.getNamedItemNS("*", "street");
assertNull("namednodemapgetnameditemns05", attribute);
|
|