use of org.w3c.dom.Attr 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.Attr in project robovm by robovm.
the class NodeIsSupported method testIsSupported2.
public void testIsSupported2() throws Throwable {
Document doc;
Attr attribute;
String version = "";
String version1 = "1.0";
String version2 = "2.0";
String featureCore;
String featureXML;
boolean success;
List<String> featuresXML = new ArrayList<String>();
featuresXML.add("XML");
featuresXML.add("xmL");
List<String> featuresCore = new ArrayList<String>();
featuresCore.add("Core");
featuresCore.add("CORE");
doc = (Document) load("staffNS", builder);
attribute = doc.createAttribute("TestAttr");
for (int indexN10064 = 0; indexN10064 < featuresXML.size(); indexN10064++) {
featureXML = (String) featuresXML.get(indexN10064);
success = attribute.isSupported(featureXML, version);
assertTrue("nodeissupported02_XML1", success);
success = attribute.isSupported(featureXML, version1);
assertTrue("nodeissupported02_XML2", success);
}
for (int indexN1007D = 0; indexN1007D < featuresCore.size(); indexN1007D++) {
featureCore = (String) featuresCore.get(indexN1007D);
success = attribute.isSupported(featureCore, version);
assertTrue("nodeissupported02_Core1", success);
success = attribute.isSupported(featureCore, version1);
success = attribute.isSupported(featureCore, version2);
assertTrue("nodeissupported02_Core3", success);
}
}
use of org.w3c.dom.Attr in project robovm by robovm.
the class NodeSetPrefix method testSetPrefix7.
public void testSetPrefix7() throws Throwable {
Document doc;
Attr attribute;
doc = (Document) load("staffNS", builder);
attribute = doc.createAttributeNS("http://www.w3.org/DOM/Test/L2", "abc:elem");
{
boolean success = false;
try {
attribute.setPrefix("xmlns");
} catch (DOMException ex) {
success = (ex.code == DOMException.NAMESPACE_ERR);
}
assertTrue("throw_NAMESPACE_ERR", success);
}
}
use of org.w3c.dom.Attr 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.Attr 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);
}
}
Aggregations