summaryrefslogtreecommitdiffstats
path: root/org/madore/damlengine/TodoKillAcronymElement.java
diff options
context:
space:
mode:
authorDavid A. Madore <david+git@madore.org>2011-09-07 12:37:42 +0200
committerDavid A. Madore <david+git@madore.org>2011-09-07 13:11:10 +0200
commit5acce829dc6ded492cca5ec87cd8bdbdb81667a5 (patch)
tree3369fb604531114f1b1807de43f2fb67ffb0e8e8 /org/madore/damlengine/TodoKillAcronymElement.java
parentbc2b0d5215873a68d336e4a942a9ae860b9b9bd4 (diff)
downloaddamlengine-5acce829dc6ded492cca5ec87cd8bdbdb81667a5.tar.gz
damlengine-5acce829dc6ded492cca5ec87cd8bdbdb81667a5.tar.bz2
damlengine-5acce829dc6ded492cca5ec87cd8bdbdb81667a5.zip
Try to produce HTML5/XHTML5 (polyglot) output.
Diffstat (limited to 'org/madore/damlengine/TodoKillAcronymElement.java')
-rw-r--r--org/madore/damlengine/TodoKillAcronymElement.java58
1 files changed, 58 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoKillAcronymElement.java b/org/madore/damlengine/TodoKillAcronymElement.java
new file mode 100644
index 0000000..65664e9
--- /dev/null
+++ b/org/madore/damlengine/TodoKillAcronymElement.java
@@ -0,0 +1,58 @@
+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 lang = LangHelper.getLangNorec(node);
+ if ( lang != null )
+ LangHelper.setLangNorec(newNode, lang);
+ ArrayList<Attr> 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<Node> childList = getChildList(node);
+ ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(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);
+ }
+
+}