use of org.w3c.dom.NamedNodeMap in project nokogiri by sparklemotion.
the class XmlDocument method removeNamespceRecursively.
private void removeNamespceRecursively(ThreadContext context, XmlNode xmlNode) {
Node node = xmlNode.node;
if (node.getNodeType() == Node.ELEMENT_NODE) {
node.setPrefix(null);
NokogiriHelpers.renameNode(node, null, node.getLocalName());
NamedNodeMap attrs = node.getAttributes();
for (int i = 0; i < attrs.getLength(); i++) {
Attr attr = (Attr) attrs.item(i);
if (isNamespace(attr.getNodeName())) {
((org.w3c.dom.Element) node).removeAttributeNode(attr);
} else {
attr.setPrefix(null);
NokogiriHelpers.renameNode(attr, null, attr.getLocalName());
}
}
}
XmlNodeSet nodeSet = (XmlNodeSet) xmlNode.children(context);
for (long i = 0; i < nodeSet.length(); i++) {
XmlNode childNode = (XmlNode) nodeSet.slice(context, RubyFixnum.newFixnum(context.getRuntime(), i));
removeNamespceRecursively(context, childNode);
}
}
use of org.w3c.dom.NamedNodeMap in project robovm by robovm.
the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS6.
// Assumes validation.
// public void testSetNamedItemNS5() throws Throwable {
// Document doc;
// DocumentType docType;
// NamedNodeMap entities;
// NamedNodeMap notations;
// Entity entity;
// Notation notation;
//
// doc = (Document) load("staffNS", builder);
// docType = doc.getDoctype();
// entities = docType.getEntities();
// assertNotNull("entitiesNotNull", entities);
// notations = docType.getNotations();
// assertNotNull("notationsNotNull", notations);
// entity = (Entity) entities.getNamedItem("ent1");
// notation = (Notation) notations.getNamedItem("notation1");
//
// {
// boolean success = false;
// try {
// entities.setNamedItemNS(entity);
// } catch (DOMException ex) {
// success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
// }
// assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_entities", success);
// }
//
// {
// boolean success = false;
// try {
// notations.setNamedItemNS(notation);
// } catch (DOMException ex) {
// success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR);
// }
// assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR_notations", success);
// }
// }
public void testSetNamedItemNS6() throws Throwable {
Document doc;
NamedNodeMap attributes;
NodeList elementList;
Element element;
Attr attr;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("*", "address");
element = (Element) elementList.item(0);
attributes = element.getAttributes();
attr = (Attr) attributes.getNamedItemNS("http://www.usa.com", "domestic");
element = (Element) elementList.item(1);
attributes = element.getAttributes();
{
boolean success = false;
try {
attributes.setNamedItemNS(attr);
} catch (DOMException ex) {
success = (ex.code == DOMException.INUSE_ATTRIBUTE_ERR);
}
assertTrue("namednodemapsetnameditemns06", success);
}
}
use of org.w3c.dom.NamedNodeMap in project robovm by robovm.
the class NamedNodeMapSetNamedItemNS method testSetNamedItemNS4.
public void testSetNamedItemNS4() throws Throwable {
Document doc;
DOMImplementation domImpl;
Document docAlt;
DocumentType docType = null;
NamedNodeMap attributes;
NodeList elementList;
Element element;
Attr attrAlt;
String nullNS = null;
doc = (Document) load("staffNS", builder);
elementList = doc.getElementsByTagNameNS("*", "address");
element = (Element) elementList.item(1);
attributes = element.getAttributes();
domImpl = doc.getImplementation();
docAlt = domImpl.createDocument(nullNS, "newDoc", docType);
attrAlt = docAlt.createAttributeNS(nullNS, "street");
{
boolean success = false;
try {
attributes.setNamedItemNS(attrAlt);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
}
use of org.w3c.dom.NamedNodeMap in project robovm by robovm.
the class SetNamedItemNS method testSetNamedItemNS2.
public void testSetNamedItemNS2() throws Throwable {
String namespaceURI = "http://www.usa.com";
String qualifiedName = "dmstc:domestic";
Document doc;
Document anotherDoc;
Node arg;
NodeList elementList;
Node testAddress;
NamedNodeMap attributes;
doc = (Document) load("staffNS", builder);
anotherDoc = (Document) load("staffNS", builder);
arg = anotherDoc.createAttributeNS(namespaceURI, qualifiedName);
arg.setNodeValue("Maybe");
elementList = doc.getElementsByTagName("address");
testAddress = elementList.item(0);
attributes = testAddress.getAttributes();
{
boolean success = false;
try {
attributes.setNamedItemNS(arg);
} catch (DOMException ex) {
success = (ex.code == DOMException.WRONG_DOCUMENT_ERR);
}
assertTrue("throw_WRONG_DOCUMENT_ERR", success);
}
}
use of org.w3c.dom.NamedNodeMap in project robovm by robovm.
the class NamedNodeMapGetNamedItemNS method testGetNamedItemNS4.
public void testGetNamedItemNS4() throws Throwable {
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);
}
Aggregations