From 7d6eccbd43ba703306328e133c43e0760ceead8c Mon Sep 17 00:00:00 2001 From: "David A. Madore" Date: Tue, 13 Apr 2010 15:47:59 +0200 Subject: Handle d:xempty attribute, as proof of concept. --- org/madore/damlengine/DamlEngine.java | 2 +- org/madore/damlengine/TodoAttr.java | 13 +++++++------ org/madore/damlengine/XemptyAttrHandler.java | 14 ++++++++++++++ 3 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 org/madore/damlengine/XemptyAttrHandler.java (limited to 'org/madore') diff --git a/org/madore/damlengine/DamlEngine.java b/org/madore/damlengine/DamlEngine.java index 822b645..a2ce87e 100644 --- a/org/madore/damlengine/DamlEngine.java +++ b/org/madore/damlengine/DamlEngine.java @@ -13,7 +13,7 @@ public final class DamlEngine { public static final String DAML_NS = "http://www.madore.org/~david/NS/daml/"; - private static Document doc; + static Document doc; private DamlEngine() { } // Forbid instantiation diff --git a/org/madore/damlengine/TodoAttr.java b/org/madore/damlengine/TodoAttr.java index d4d877e..c4e554a 100644 --- a/org/madore/damlengine/TodoAttr.java +++ b/org/madore/damlengine/TodoAttr.java @@ -14,12 +14,13 @@ public class TodoAttr extends TodoItem { { Class[] handlerArgTypes = new Class[]{ TodoAttr.class }; damlHandlers = new HashMap(); - // try { - // ; - // } catch (NoSuchMethodException e) { - // // FIXME: this isn't good... - // throw new Error("this is impossible"); - // } + try { + damlHandlers.put("xempty", + XemptyAttrHandler.class.getMethod("handle", handlerArgTypes)); + } catch (NoSuchMethodException e) { + // FIXME: this isn't good... + throw new Error("this is impossible"); + } } Attr attr; diff --git a/org/madore/damlengine/XemptyAttrHandler.java b/org/madore/damlengine/XemptyAttrHandler.java new file mode 100644 index 0000000..3120d26 --- /dev/null +++ b/org/madore/damlengine/XemptyAttrHandler.java @@ -0,0 +1,14 @@ +package org.madore.damlengine; + +import org.w3c.dom.*; + +public class XemptyAttrHandler { + + private XemptyAttrHandler() { } + + public static void handle(TodoAttr that) { + that.owner.removeAttribute(that.attr.getName()); + that.owner.appendChild(DamlEngine.doc.createComment(" EMPTY ")); + } + +} -- cgit v1.2.3