@Override public Text replaceWholeText(String content) throws DOMException { Text text = getDomElement().replaceWholeText(content); getSoapDocument().registerChildNodes(text, true); return text; }
/** * @param content * @return * @throws org.w3c.dom.DOMException * @see org.w3c.dom.Text#replaceWholeText(java.lang.String) */ public Text replaceWholeText(String content) { return getParent().replaceWholeText(content); }
Text text; void callsomefunctionthousendtimes(){ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); dbf.setValidating(false); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new FileInputStream(new File("./myXML.xml"))); text = doc.createTextNode(""); Element element = doc.getDocumentElement(); NodeList node1 = doc.getElementsByTagName("name"); Element fn= (Element) node1.item(0); //TODO call your functionName(content) 1000 times here fn.appendChild(text); printtoXML(doc); } void functionName(String content){ text = text.replaceWholeText(text.getWholeText() + content); }
public DOMText replaceWholeText(String content) throws DOMException { try { return wrap(_delegate.replaceWholeText(content)); } catch (org.w3c.dom.DOMException ex) { throw wrap(ex); } }
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList itemList; Element elementName; Text textNode; Text replacedText; doc = (Document) load("hc_staff", true); itemList = doc.getElementsByTagName("strong"); elementName = (Element) itemList.item(0); textNode = (Text) elementName.getFirstChild(); replacedText = textNode.replaceWholeText(""); assertNull("textreplacewholetext02", replacedText); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; Text textNode; Text replacedText; String wholeText; doc = (Document) load("hc_staff", true); textNode = doc.createTextNode("New Text"); replacedText = textNode.replaceWholeText(""); assertNull("retvalIsNull", replacedText); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList itemList; Element elementName; Text textNode; CDATASection cdataNode; Text replacedText; String wholeText; Node appendedChild; doc = (Document) load("hc_staff", true); itemList = doc.getElementsByTagName("strong"); elementName = (Element) itemList.item(0); textNode = doc.createTextNode("New Text"); cdataNode = doc.createCDATASection("New CDATA"); appendedChild = elementName.appendChild(textNode); appendedChild = elementName.appendChild(cdataNode); textNode = (Text) elementName.getFirstChild(); replacedText = textNode.replaceWholeText("New Text and Cdata"); wholeText = replacedText.getWholeText(); assertEquals("textreplacewholetext05", "New Text and Cdata", wholeText); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList itemList; Element elementName; Text textNode; Text replacedText; String wholeText; doc = (Document) load("hc_staff", true); itemList = doc.getElementsByTagName("strong"); elementName = (Element) itemList.item(0); textNode = (Text) elementName.getFirstChild(); replacedText = textNode.replaceWholeText("New Content"); wholeText = replacedText.getWholeText(); assertEquals("textreplacewholetext01_1", "New Content", wholeText); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList itemList; Element elementStrong; Text textNode; EntityReference erefNode; Text replacedText; Node appendedChild; String nodeValue; doc = (Document) load("hc_staff", false); itemList = doc.getElementsByTagName("strong"); elementStrong = (Element) itemList.item(0); textNode = doc.createTextNode("New Text"); erefNode = doc.createEntityReference("beta"); appendedChild = elementStrong.appendChild(textNode); appendedChild = elementStrong.appendChild(erefNode); textNode = (Text) elementStrong.getFirstChild(); replacedText = textNode.replaceWholeText("New Text and Cdata"); nodeValue = textNode.getNodeValue(); assertEquals("textreplacewholetext06", "New Text and Cdata", nodeValue); } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; NodeList itemList; Element p; EntityReference entRef; Node node; doc = (Document) load("barfoo", true); itemList = doc.getElementsByTagName("p"); p = (Element) itemList.item(0); entRef = doc.createEntityReference("ent2"); node = p.appendChild(entRef); node = p.getFirstChild(); { boolean success = false; try { node = ((Text) /*Node */node).replaceWholeText("yo"); } catch (DOMException ex) { success = (ex.code == DOMException.NO_MODIFICATION_ALLOWED_ERR); } assertTrue("throw_NO_MODIFICATION_ALLOWED_ERR", success); } } /**
/** * Runs the test case. * @throws Throwable Any uncaught exception causes test to fail */ public void runTest() throws Throwable { Document doc; Text textNode; Text replacedText; String wholeText; doc = (Document) load("hc_staff", true); textNode = doc.createTextNode("New Text"); replacedText = textNode.replaceWholeText(" a b c b "); wholeText = replacedText.getWholeText(); assertEquals("textreplacewholetext03", " a b c b ", wholeText); } /**
appendedChild = elementName.appendChild(textNode); textNode = (Text) elementName.getFirstChild(); replacedText = textNode.replaceWholeText("New Text and Cdata"); textNode = (Text) elementName.getFirstChild(); assertSame("retval_same", textNode, replacedText);
String value = text.getWholeText(); value = filterText( extractQName( text.getParentNode() ), value, apply.rule() ); text.replaceWholeText( value ); } else if( node instanceof Attr ) { Attr attr = (Attr)node;
String value = text.getWholeText(); value = filterText( extractQName( text.getParentNode() ), value, apply.rule() ); text.replaceWholeText( value ); } else if( node instanceof Attr ) { Attr attr = (Attr)node;