summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoImgAElement.java
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2011-08-26 17:28:05 +0200
committerDavid A. Madore <david+git@madore.org>2011-08-26 17:28:05 +0200
commitfc26fdba30e084a2e8a8278d09a1be08a83e0722 (patch)
tree5f2faf6413275a55683273e4fa3b9223f49967e4 /org/madore/damlengine/TodoImgAElement.java
parent961bdfc66151b9aef46149e4730110ef409e5587 (diff)
downloaddamlengine-fc26fdba30e084a2e8a8278d09a1be08a83e0722.tar.gz
damlengine-fc26fdba30e084a2e8a8278d09a1be08a83e0722.tar.bz2
damlengine-fc26fdba30e084a2e8a8278d09a1be08a83e0722.zip
Handle d:img-a element.
Diffstat (limited to 'org/madore/damlengine/TodoImgAElement.java')
-rw-r--r--org/madore/damlengine/TodoImgAElement.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoImgAElement.java b/org/madore/damlengine/TodoImgAElement.java
new file mode 100644
index 0000000..25a8263
--- /dev/null
+++ b/org/madore/damlengine/TodoImgAElement.java
@@ -0,0 +1,44 @@
+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.getParentNode().replaceChild(a, node);
+ Element img = ctx.doc.createElementNS(DamlEngine.XHTML_NS, "img");
+ a.appendChild(img);
+ ArrayList<Attr> attrList = getAttrList(this.node);
+ for ( Attr attr : attrList ) {
+ if ( attr.getNamespaceURI() == null ) {
+ String attName = attr.getLocalName();
+ if ( attName == "src" )
+ a.setAttributeNS(null, "href", attr.getValue());
+ node.removeAttributeNode(attr);
+ img.setAttributeNodeNS(attr);
+ }
+ }
+ }
+
+}