1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
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() {
System.err.println("warning: weblog element should not be processed this way!");
Node parent = node.getParentNode();
String explicitLang = 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 ( explicitLang != null )
LangHelper.setWeakLangNorec((Element)child, explicitLang);
TodoElement it
= TodoElement.getTodoElement((Element)child, this.ctx, this);
toProcess.add(it);
}
}
Element token = ctx.doc.createElementNS(DamlEngine.DAML_NS,
"d:implicit-do-comments-script");
node.getParentNode().insertBefore(token, node);
node.getParentNode().insertBefore(ctx.doc.createTextNode("\n"), node);
toProcess.add(new TodoCommentsScript(token, ctx, this));
parent.removeChild(node);
this.ownerDeque.registerAtStart(toProcess);
}
}
|