package org.madore.damlengine; import java.util.ArrayList; import org.w3c.dom.*; public final class TodoKillAcronymElement extends TodoDefaultElement { public static class Factory extends TodoElement.Factory { @Override public TodoKillAcronymElement newItem(Element node, Context ctx, TodoItem caller) { return new TodoKillAcronymElement(node, ctx, caller); } } public TodoKillAcronymElement(Element node, Context ctx, TodoItem caller) { super(node, ctx, caller); } @Override public void handleNodeOnly() { Element newNode = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "abbr"); if ( node.hasAttributeNS(null, "class") ) newNode.setAttributeNS(null, "class", "acronym "+node.getAttributeNS(null, "class")); else newNode.setAttributeNS(null, "class", "acronym"); String explicitLang = LangHelper.getLangNorec(node); if ( explicitLang != null ) LangHelper.setLangNorec(newNode, explicitLang); ArrayList attrList = getAttrList(this.node); for ( Attr attr : attrList ) { if ( attr.getNamespaceURI() == null ) { String attName = attr.getLocalName(); if ( attName.equals("class") ) continue; node.removeAttributeNode(attr); newNode.setAttributeNodeNS(attr); } } ArrayList childList = getChildList(node); ArrayList toProcess = new ArrayList(childList.size()); node.getParentNode().replaceChild(newNode, node); for ( Node child : childList ) { newNode.appendChild(child); if ( child.getNodeType() == Node.ELEMENT_NODE ) { TodoElement it = TodoElement.getTodoElement((Element)child, this.ctx, this); toProcess.add(it); } } this.ownerDeque.registerAtStart(toProcess); } }