use of org.w3c.dom.Attr in project robovm by robovm.
the class NamespaceURI method testGetNamespaceURI2.
/**
* Runs the test case.
*
* @throws Throwable
* Any uncaught exception causes test to fail
*/
// Assumes validation.
// public void testGetNamespaceURI1() throws Throwable {
// Document doc;
// NodeList elementList;
// Element testAddr;
// Attr addrAttr;
// String attrNamespaceURI;
// doc = (Document) load("staffNS", builder);
// elementList = doc.getElementsByTagName("emp:address");
// testAddr = (Element) elementList.item(0);
// addrAttr = testAddr.getAttributeNodeNS("http://www.nist.gov",
// "district");
// attrNamespaceURI = addrAttr.getNamespaceURI();
// assertEquals("namespaceURI", "http://www.nist.gov", attrNamespaceURI);
// }
public void testGetNamespaceURI2() throws Throwable {
Document doc;
NodeList elementList;
Element testAddr;
Attr addrAttr;
String attrNamespaceURI;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = (Element) elementList.item(0);
assertNotNull("empAddressNotNull", testAddr);
addrAttr = testAddr.getAttributeNodeNS("http://www.nist.gov", "domestic");
attrNamespaceURI = addrAttr.getNamespaceURI();
assertEquals("namespaceURI", "http://www.nist.gov", attrNamespaceURI);
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class NodeGetNamespaceURI method testGetNamespaceURI.
/**
* Runs the test case.
* @throws Throwable Any uncaught exception causes test to fail
*/
public void testGetNamespaceURI() throws Throwable {
Document doc;
Element element;
Element elementNS;
Attr attr;
Attr attrNS;
String elemNSURI;
String elemNSURINull;
String attrNSURI;
String attrNSURINull;
String nullNS = null;
doc = (Document) load("staff", builder);
element = doc.createElementNS(nullNS, "elem");
elementNS = doc.createElementNS("http://www.w3.org/DOM/Test/elem", "qual:qelem");
attr = doc.createAttributeNS(nullNS, "attr");
attrNS = doc.createAttributeNS("http://www.w3.org/DOM/Test/attr", "qual:qattr");
elemNSURI = elementNS.getNamespaceURI();
elemNSURINull = element.getNamespaceURI();
attrNSURI = attrNS.getNamespaceURI();
attrNSURINull = attr.getNamespaceURI();
assertEquals("nodegetnamespaceuri03_elemNSURI", "http://www.w3.org/DOM/Test/elem", elemNSURI);
assertNull("nodegetnamespaceuri03_1", elemNSURINull);
assertEquals("nodegetnamespaceuri03_attrNSURI", "http://www.w3.org/DOM/Test/attr", attrNSURI);
assertNull("nodegetnamespaceuri03_2", attrNSURINull);
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class NodeHasAttributes method testHasAttributes4.
public void testHasAttributes4() throws Throwable {
Document doc;
Document newDoc;
DocumentType docType = null;
DOMImplementation domImpl;
Element element;
Element elementTest;
Element elementDoc;
Attr attribute;
NodeList elementList;
boolean hasAttributes;
doc = (Document) load("staffNS", builder);
domImpl = doc.getImplementation();
newDoc = domImpl.createDocument("http://www.w3.org/DOM/Test", "test", docType);
element = newDoc.createElementNS("http://www.w3.org/DOM/Test", "dom:elem");
attribute = newDoc.createAttribute("attr");
element.setAttributeNode(attribute);
elementDoc = newDoc.getDocumentElement();
elementDoc.appendChild(element);
elementList = newDoc.getElementsByTagNameNS("http://www.w3.org/DOM/Test", "elem");
elementTest = (Element) elementList.item(0);
hasAttributes = elementTest.hasAttributes();
assertTrue("nodehasattributes04", hasAttributes);
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class SetAttributeNS method testSetAttributeNS4.
// Assumes validation.
// public void testSetAttributeNS3() throws Throwable {
// String namespaceURI = "www.xyz.com";
// String qualifiedName = "emp:local1";
// Document doc;
// NodeList genderList;
// Node gender;
// NodeList genList;
// Node gen;
// NodeList gList;
// Element genElement;
// int nodeType;
// doc = (Document) load("staffNS", builder);
// genderList = doc.getElementsByTagName("gender");
// gender = genderList.item(2);
// genList = gender.getChildNodes();
// gen = genList.item(0);
// nodeType = (int) gen.getNodeType();
//
// if (1 == nodeType) {
// gen = doc.createEntityReference("ent4");
// assertNotNull("createdEntRefNotNull", gen);
// }
// gList = gen.getChildNodes();
// genElement = (Element) gList.item(0);
// assertNotNull("notnull", genElement);
//
// {
// boolean success = false;
// try {
// genElement.setAttributeNS(namespaceURI, qualifiedName,
// "newValue");
// } catch (DOMException ex) {
// success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
// }
// assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success);
// }
// }
public void testSetAttributeNS4() throws Throwable {
Document doc;
NodeList elementList;
Node testAddr;
Attr addrAttr;
String resultAttr;
String resultNamespaceURI;
String resultLocalName;
String resultPrefix;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
((Element) /* Node */
testAddr).setAttributeNS("http://www.nist.gov", "newprefix:zone", "newValue");
addrAttr = ((Element) /* Node */
testAddr).getAttributeNodeNS("http://www.nist.gov", "zone");
resultAttr = ((Element) /* Node */
testAddr).getAttributeNS("http://www.nist.gov", "zone");
assertEquals("attrValue", "newValue", resultAttr);
resultNamespaceURI = addrAttr.getNamespaceURI();
assertEquals("nsuri", "http://www.nist.gov", resultNamespaceURI);
resultLocalName = addrAttr.getLocalName();
assertEquals("lname", "zone", resultLocalName);
resultPrefix = addrAttr.getPrefix();
assertEquals("prefix", "newprefix", resultPrefix);
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class SetAttributeNS method testSetAttributeNS9.
public void testSetAttributeNS9() throws Throwable {
String localName = "newAttr";
String namespaceURI = "http://www.newattr.com";
String qualifiedName = "emp:newAttr";
Document doc;
NodeList elementList;
Node testAddr;
Attr addrAttr;
String resultAttr;
String resultNamespaceURI;
String resultLocalName;
String resultPrefix;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagName("emp:address");
testAddr = elementList.item(0);
assertNotNull("empAddrNotNull", testAddr);
((Element) /* Node */
testAddr).setAttributeNS(namespaceURI, qualifiedName, "newValue");
addrAttr = ((Element) /* Node */
testAddr).getAttributeNodeNS(namespaceURI, localName);
resultAttr = ((Element) /* Node */
testAddr).getAttributeNS(namespaceURI, localName);
assertEquals("attrValue", "newValue", resultAttr);
resultNamespaceURI = addrAttr.getNamespaceURI();
assertEquals("nsuri", "http://www.newattr.com", resultNamespaceURI);
resultLocalName = addrAttr.getLocalName();
assertEquals("lname", "newAttr", resultLocalName);
resultPrefix = addrAttr.getPrefix();
assertEquals("prefix", "emp", resultPrefix);
}
Aggregations