From 5acce829dc6ded492cca5ec87cd8bdbdb81667a5 Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Wed, 7 Sep 2011 12:37:42 +0200 Subject: Try to produce HTML5/XHTML5 (polyglot) output. --- org/madore/damlengine/TodoKillAcronymElement.java | 58 +++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 org/madore/damlengine/TodoKillAcronymElement.java (limited to 'org/madore/damlengine/TodoKillAcronymElement.java') 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 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); + } + +} -- cgit v1.2.3