Skip to content

Commit 93dc8d0

Browse files
author
Tobias Wiessner
committed
XHTML output
1 parent a37c75a commit 93dc8d0

3 files changed

Lines changed: 31 additions & 6 deletions

File tree

de/uni_stuttgart/ils/reqif4j/xhtml/XHTMLElement.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,11 @@ private void addChildren(Node xhtmlElement) {
106106

107107
@Override
108108
public String toString() {
109-
return tagName + (!children.isEmpty() ? "\t" + children.toString() : "");
109+
StringBuilder sb = new StringBuilder();
110+
sb.append('<').append(tagName).append('>');
111+
sb.append((!children.isEmpty() ? this.listToString(children) : ""));
112+
sb.append("</").append(tagName).append('>');
113+
return sb.toString();
110114
}
111115

112116
}

de/uni_stuttgart/ils/reqif4j/xhtml/XHTMLElementObject.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,11 @@ public XHTMLElementObject(Node xhtmlElement, XHTMLNode parent) {
2626

2727
@Override
2828
public String toString() {
29-
return tagName + " {" + data + "}" + (!children.isEmpty() ? "\t" + children.toString() : "");
29+
StringBuilder sb = new StringBuilder();
30+
sb.append('<').append(tagName).append(" ").append(data).append('>');
31+
sb.append((!children.isEmpty() ? "\t" + this.listToString(children) : ""));
32+
sb.append("</").append(tagName).append('>');
33+
return sb.toString();
3034
}
3135

3236
}

de/uni_stuttgart/ils/reqif4j/xhtml/XHTMLNode.java

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
import org.w3c.dom.Node;
44

5+
import java.util.List;
56

67

78
public class XHTMLNode {
89

910
protected String tagName;
1011
protected XHTMLNode parent = null;
12+
protected Node node;
1113

1214

1315
/**
@@ -27,19 +29,34 @@ public XHTMLNode getParent() {
2729

2830

2931
public XHTMLNode(Node xhtmlElement) {
30-
32+
33+
this.node = xhtmlElement;
3134
this.tagName = xhtmlElement.getNodeName();
3235
}
3336

3437
public XHTMLNode(Node xhtmlElement, XHTMLNode parent) {
35-
38+
this.node = xhtmlElement;
3639
this.tagName = xhtmlElement.getNodeName();
3740
this.parent = parent;
3841
}
3942

4043
@Override
4144
public String toString() {
42-
return tagName;
45+
StringBuilder sb = new StringBuilder();
46+
sb.append("<").append(tagName).append(">");
47+
sb.append("</").append(tagName).append(">");
48+
return sb.toString();
49+
}
50+
51+
public Node getNode() {
52+
return node;
53+
}
54+
55+
protected String listToString(List<XHTMLNode> list){
56+
StringBuilder sb = new StringBuilder();
57+
for(XHTMLNode node : list){
58+
sb.append(node.toString());
59+
}
60+
return sb.toString();
4361
}
44-
4562
}

0 commit comments

Comments
 (0)