public static Element replaceTextElement(Txn txn,ElementImpl parent,String namespaceName,String localName,String value,boolean firstChild) {
ElementImpl textE = (ElementImpl)DOM.findChild(parent,namespaceName,localName);
if (textE==null) {
textE = (ElementImpl)parent.getOwnerDocument().createElementNS(namespaceName,localName);
final NodeListImpl nl = new NodeListImpl(1);
nl.add(textE);
if (firstChild) {
parent.insertAfter(txn,nl,parent.getFirstChild());
} else {
parent.appendChildren(txn,nl,-1);
}