use of org.w3c.dom.Attr in project robovm by robovm.
the class ElementSetAttributeNodeNS method testSetAttributeNodeNS2.
public void testSetAttributeNodeNS2() throws Throwable {
Document doc;
Element element;
Element element2;
Attr attribute;
Attr attributeCloned;
Attr newAttr;
NodeList elementList;
String attrName;
String attrValue;
String nullNS = null;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("http://www.nist.gov", "address");
element = (Element) elementList.item(1);
attribute = element.getAttributeNodeNS(nullNS, "street");
attributeCloned = (Attr) attribute.cloneNode(true);
element2 = (Element) elementList.item(2);
newAttr = element2.setAttributeNodeNS(attributeCloned);
attrName = newAttr.getNodeName();
attrValue = newAttr.getNodeValue();
assertEquals("elementsetattributenodens02_attrName", "street", attrName);
assertEquals("elementsetattributenodens02_attrValue", "Yes", attrValue);
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class ElementSetAttributeNodeNS method testSetAttributeNodeNS1.
/**
* Runs the test case.
*
* @throws Throwable
* Any uncaught exception causes test to fail
*/
public void testSetAttributeNodeNS1() throws Throwable {
Document doc;
Element element;
Attr attribute1;
Attr attribute2;
Attr attrNode;
String attrName;
String attrNS;
NamedNodeMap attributes;
int length;
doc = (Document) load("staff", builder);
element = doc.createElementNS("http://www.w3.org/DOM/Test/Level2", "new:element");
attribute1 = doc.createAttributeNS("http://www.w3.org/DOM/Test/att1", "p1:att");
attribute2 = doc.createAttributeNS("http://www.w3.org/DOM/Test/att1", "p2:att");
attribute2.setValue("value2");
element.setAttributeNodeNS(attribute1);
element.setAttributeNodeNS(attribute2);
attrNode = element.getAttributeNodeNS("http://www.w3.org/DOM/Test/att1", "att");
attrName = attrNode.getNodeName();
attrNS = attrNode.getNamespaceURI();
assertEquals("elementsetattributenodens01_attrName", "p2:att", attrName);
assertEquals("elementsetattributenodens01_attrNS", "http://www.w3.org/DOM/Test/att1", attrNS);
attributes = element.getAttributes();
length = (int) attributes.getLength();
assertEquals("length", 1, length);
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class ElementSetAttributeNodeNS method testSetAttributeNodeNS5.
public void testSetAttributeNodeNS5() throws Throwable {
Document doc;
Document docAlt;
Element element;
Attr attribute;
doc = (Document) load("staffNS", builder);
docAlt = (Document) load("staffNS", builder);
element = doc.createElementNS("http://www.w3.org/DOM/Test", "elem1");
attribute = docAlt.createAttributeNS("http://www.w3.org/DOM/Test", "attr");
{
boolean success = false;
try {
element.setAttributeNodeNS(attribute);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class ElementSetAttributeNodeNS method testSetAttributeNodeNS4.
public void testSetAttributeNodeNS4() throws Throwable {
Document doc;
Element element1;
Element element2;
Attr attribute;
doc = (Document) load("staffNS", builder);
element1 = doc.createElementNS("http://www.w3.org/DOM/Test", "elem1");
element2 = doc.createElementNS("http://www.w3.org/DOM/Test", "elem2");
attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test", "attr");
element1.setAttributeNodeNS(attribute);
{
boolean success = false;
try {
element2.setAttributeNodeNS(attribute);
} catch (DOMException ex) {
success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR);
}
assertTrue("elementsetattributenodens04", success);
}
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class GetAttributeNodeNS method testGetAttributeNodeNS2.
public void testGetAttributeNodeNS2() throws Throwable {
Document doc;
NodeList elementList;
Element testAddr;
Attr attribute;
String attrName;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = (Element) elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
attribute = testAddr.getAttributeNodeNS("http://www.nist.gov", "domestic");
attrName = attribute.getNodeName();
assertEquals("attrName", "emp:domestic", attrName);
}
Aggregations