blob: d285d8f3f60e6de17609aa857e053396b370f066 (
plain)
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
|
package org.madore.damlengine;
import java.util.regex.Pattern;
import org.w3c.dom.*;
public final class TodoExtraStyleOrScriptElement extends TodoDefaultElement {
public static class Factory extends TodoElement.Factory {
final TodoStyleOrScript.Type t;
public Factory(TodoStyleOrScript.Type t) {
super();
this.t = t;
}
@Override
public TodoExtraStyleOrScriptElement newItem(Element node,
Context ctx,
TodoItem caller) {
return new TodoExtraStyleOrScriptElement(t, node, ctx, caller);
}
}
final TodoStyleOrScript.Type t;
public TodoExtraStyleOrScriptElement(TodoStyleOrScript.Type t,
Element node,
Context ctx,
TodoItem caller) {
super(node, ctx, caller);
this.t = t;
}
@Override
public void handleNodeOnly() {
String content = node.getTextContent();
if ( t == TodoStyleOrScript.Type.SCRIPT )
ctx.gc.scriptContent.append(content);
else
ctx.gc.styleContent.append(content);
Node ws = node.getNextSibling();
if ( ws != null && ( ws.getNodeType() == Node.TEXT_NODE
|| ws.getNodeType() == Node.CDATA_SECTION_NODE )
&& Pattern.matches("^\\s*$",((CharacterData)ws).getData()) )
node.getParentNode().removeChild(ws);
node.getParentNode().removeChild(node);
}
}
|