summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org/madore/damlengine/TodoElement.java1
-rw-r--r--org/madore/damlengine/TodoWeblogElement.java48
2 files changed, 49 insertions, 0 deletions
diff --git a/org/madore/damlengine/TodoElement.java b/org/madore/damlengine/TodoElement.java
index 8db448c..7449ea3 100644
--- a/org/madore/damlengine/TodoElement.java
+++ b/org/madore/damlengine/TodoElement.java
@@ -33,6 +33,7 @@ public abstract class TodoElement extends TodoItem {
damlDefaultFactory = new TodoDefaultElement.Factory();
damlFactories.put("daml", new TodoDamlElement.Factory());
damlFactories.put("body", new TodoBodyElement.Factory());
+ damlFactories.put("weblog", new TodoWeblogElement.Factory());
damlFactories.put("title", new TitleDisambiguationFactory());
damlFactories.put("subtitle", new TodoSubtitleElement.Factory());
damlFactories.put("translation", new TodoTranslationElement.Factory());
diff --git a/org/madore/damlengine/TodoWeblogElement.java b/org/madore/damlengine/TodoWeblogElement.java
new file mode 100644
index 0000000..2b42820
--- /dev/null
+++ b/org/madore/damlengine/TodoWeblogElement.java
@@ -0,0 +1,48 @@
+package org.madore.damlengine;
+
+import java.util.ArrayList;
+import java.util.regex.Pattern;
+import org.w3c.dom.*;
+
+public final class TodoWeblogElement extends TodoDefaultElement {
+
+ public static class Factory extends TodoElement.Factory {
+ @Override
+ public TodoWeblogElement newItem(Element node,
+ Context ctx,
+ TodoItem caller) {
+ return new TodoWeblogElement(node, ctx, caller);
+ }
+ }
+
+ public TodoWeblogElement(Element node,
+ Context ctx,
+ TodoItem caller) {
+ super(node, ctx, caller);
+ }
+
+ @Override
+ public void handleNodeOnly() {
+ Node parent = node.getParentNode();
+ String lang = LangHelper.getLangNorec(node);
+ ArrayList<Node> childList = getChildList(this.node);
+ ArrayList<TodoElement> toProcess = new ArrayList<TodoElement>(childList.size()+8);
+ for ( Node child : childList ) {
+ if ( child.getNodeType() == Node.TEXT_NODE
+ || child.getNodeType() == Node.CDATA_SECTION_NODE ) {
+ if ( ! Pattern.matches("^\\s*$",((CharacterData)child).getData()) )
+ throw new IllegalArgumentException("weblog element cannot contain text");
+ }
+ parent.insertBefore(child, node);
+ if ( child.getNodeType() == Node.ELEMENT_NODE ) {
+ if ( lang != null )
+ LangHelper.setLangRec((Element)child, lang); // Dubious
+ TodoElement it
+ = TodoElement.getTodoElement((Element)child, this.ctx, this);
+ toProcess.add(it);
+ }
+ }
+ this.ownerDeque.registerAtStart(toProcess);
+ }
+
+}