package org.madore.damlengine; import java.util.ArrayList; import org.w3c.dom.*; public final class TodoImgAElement extends TodoDefaultElement { public static class Factory extends TodoElement.Factory { @Override public TodoImgAElement newItem(Element node, Context ctx, TodoItem caller) { return new TodoImgAElement(node, ctx, caller); } } public TodoImgAElement(Element node, Context ctx, TodoItem caller) { super(node, ctx, caller); } @Override public void handleNodeOnly() { String explicitLang = LangHelper.getLangNorec(node); Element a = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "a"); if ( explicitLang != null ) LangHelper.setLangNorec(node, explicitLang); Node pnode = node.getParentNode(); if ( pnode == null ) // See "FIXME" in TodoCutHere.java (node may have moved out of DOM). return; pnode.replaceChild(a, node); Element img = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "img"); a.appendChild(img); ArrayList attrList = getAttrList(this.node); for ( Attr attr : attrList ) { if ( attr.getNamespaceURI() == null ) { String attName = attr.getLocalName(); if ( attName.equals("src") ) a.setAttributeNS(null, "href", attr.getValue()); node.removeAttributeNode(attr); img.setAttributeNodeNS(attr); } } } }